diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index 5feef14ee6..ed684424dc 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -505,8 +505,8 @@ class EnableEditingSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): tool.Style.set_surface_style_props() surface_style = tool.Style.get_style_elements(style).get(self.ifc_class, None) - if self.ifc_class == "IfcExternallyDefinedSurfaceStyle": - attributes = props.external_style_attributes + attributes = tool.Style.get_style_ui_props_attributes(self.ifc_class) + if attributes is not None: attributes.clear() blenderbim.bim.helper.import_attributes2(surface_style or self.ifc_class, attributes) @@ -574,13 +574,15 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): attributes={"Textures": textures}, ) tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style) - elif self.surface_style.is_a() == "IfcExternallyDefinedSurfaceStyle": - ifcopenshell.api.run( - "style.edit_surface_style", - tool.Ifc.get(), - style=self.surface_style, - attributes=blenderbim.bim.helper.export_attributes(self.props.external_style_attributes), - ) + else: + attributes = tool.Style.get_style_ui_props_attributes(self.surface_style.is_a()) + if attributes is not None: + ifcopenshell.api.run( + "style.edit_surface_style", + tool.Ifc.get(), + style=self.surface_style, + attributes=blenderbim.bim.helper.export_attributes(attributes), + ) def add_new_style(self): material = tool.Ifc.get_object(self.style) @@ -623,14 +625,16 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): attributes={"Textures": textures}, ) tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style) - elif self.props.is_editing_class == "IfcExternallyDefinedSurfaceStyle": - surface_style = ifcopenshell.api.run( - "style.add_surface_style", - tool.Ifc.get(), - style=self.style, - ifc_class="IfcExternallyDefinedSurfaceStyle", - attributes=blenderbim.bim.helper.export_attributes(self.props.external_style_attributes), - ) + else: + attributes = tool.Style.get_style_ui_props_attributes(self.props.is_editing_class) + if attributes is not None: + surface_style = ifcopenshell.api.run( + "style.add_surface_style", + tool.Ifc.get(), + style=self.style, + ifc_class=self.props.is_editing_class, + attributes=blenderbim.bim.helper.export_attributes(attributes), + ) def get_shading_attributes(self): return { diff --git a/src/blenderbim/blenderbim/bim/module/style/prop.py b/src/blenderbim/blenderbim/bim/module/style/prop.py index 81c922a5ef..ffef612554 100644 --- a/src/blenderbim/blenderbim/bim/module/style/prop.py +++ b/src/blenderbim/blenderbim/bim/module/style/prop.py @@ -119,6 +119,7 @@ class BIMStylesProperties(PropertyGroup): is_editing_class: StringProperty(name="Is Editing Class") attributes: CollectionProperty(name="Attributes", type=Attribute) external_style_attributes: CollectionProperty(name="External Style Attributes", type=Attribute) + refraction_style_attributes: CollectionProperty(name="Refraction Style Attributes", type=Attribute) style_type: EnumProperty(items=get_style_types, default=2, name="Style Type") style_name: StringProperty(name="Style Name") surface_style_class: EnumProperty( diff --git a/src/blenderbim/blenderbim/bim/module/style/ui.py b/src/blenderbim/blenderbim/bim/module/style/ui.py index 8fce530f86..2ba47aac7e 100644 --- a/src/blenderbim/blenderbim/bim/module/style/ui.py +++ b/src/blenderbim/blenderbim/bim/module/style/ui.py @@ -134,8 +134,10 @@ class BIM_PT_styles(Panel): self.draw_externally_defined_surface_style() elif self.props.is_editing_class == "IfcSurfaceStyleWithTextures": self.draw_surface_style_with_textures() + elif self.props.is_editing_class == "IfcSurfaceStyleRefraction": + self.draw_refraction_surface_style() else: - # TODO: UI Lighting, Refract + # TODO: UI Lighting self.layout.label(text=f"{self.props.is_editing_class} UI is not yet supported.") def draw_surface_style_shading(self): @@ -238,6 +240,12 @@ class BIM_PT_styles(Panel): row.operator("bim.edit_surface_style", text="Save External Style", icon="CHECKMARK") row.operator("bim.disable_editing_style", text="", icon="CANCEL") + def draw_refraction_surface_style(self): + blenderbim.bim.helper.draw_attributes(self.props.refraction_style_attributes, self.layout) + row = self.layout.row(align=True) + row.operator("bim.edit_surface_style", text="Save Refraction Style", icon="CHECKMARK") + row.operator("bim.disable_editing_style", text="", icon="CANCEL") + class BIM_PT_style(MaterialButtonsPanel, Panel): bl_label = "Style" diff --git a/src/blenderbim/blenderbim/tool/style.py b/src/blenderbim/blenderbim/tool/style.py index bbf8bb194b..b812591291 100644 --- a/src/blenderbim/blenderbim/tool/style.py +++ b/src/blenderbim/blenderbim/tool/style.py @@ -453,6 +453,14 @@ class Style(blenderbim.core.tool.Style): results.append(uv_map) return results + @classmethod + def get_style_ui_props_attributes(self, style_type): + props = bpy.context.scene.BIMStylesProperties + if style_type == "IfcExternallyDefinedSurfaceStyle": + return props.external_style_attributes + elif style_type == "IfcSurfaceStyleRefraction": + return props.refraction_style_attributes + @classmethod def import_presentation_styles(cls, style_type): color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)