diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index 32a592b24c..8f22db9034 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -550,9 +550,19 @@ class EnableEditingSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): props.is_specular_highlight_null = True props.reflectance_method = surface_style.ReflectanceMethod - elif shading: - props.surface_colour = color_to_tuple(shading.SurfaceColour) - props.transparency = shading.Transparency or 0.0 + elif self.ifc_class == "IfcExternallyDefinedSurfaceStyle": + attributes = props.external_style_attributes + attributes.clear() + blenderbim.bim.helper.import_attributes2(surface_style, attributes) + else: + if self.ifc_class == "IfcSurfaceStyleRendering": + if shading: + props.surface_colour = color_to_tuple(shading.SurfaceColour) + props.transparency = shading.Transparency or 0.0 + elif self.ifc_class == "IfcExternallyDefinedSurfaceStyle": + attributes = props.external_style_attributes + attributes.clear() + blenderbim.bim.helper.import_attributes2(self.ifc_class, attributes) props.is_editing_style = self.style props.is_editing_class = self.ifc_class @@ -607,6 +617,13 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): attributes=self.get_rendering_attributes(), ) tool.Loader.create_surface_style_rendering(material, self.surface_style) + elif self.surface_style.is_a() == "IfcExternallyDefinedSurfaceStyle": + surface_style = 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), + ) def add_new_style(self): material = tool.Ifc.get_object(self.style) @@ -628,6 +645,14 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): attributes=self.get_rendering_attributes(), ) tool.Loader.create_surface_style_rendering(material, surface_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), + ) 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 e399e0c3a2..c8af2e0bb9 100644 --- a/src/blenderbim/blenderbim/bim/module/style/prop.py +++ b/src/blenderbim/blenderbim/bim/module/style/prop.py @@ -80,6 +80,7 @@ class BIMStylesProperties(PropertyGroup): is_editing_style: IntProperty(name="Is Editing Style") is_editing_class: StringProperty(name="Is Editing Class") attributes: CollectionProperty(name="Attributes", type=Attribute) + external_style_attributes: CollectionProperty(name="External 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 d3e97deb94..345dfc55f8 100644 --- a/src/blenderbim/blenderbim/bim/module/style/ui.py +++ b/src/blenderbim/blenderbim/bim/module/style/ui.py @@ -116,6 +116,8 @@ class BIM_PT_styles(Panel): self.draw_surface_style_shading() elif self.props.is_editing_class == "IfcSurfaceStyleRendering": self.draw_surface_style_rendering() + elif self.props.is_editing_class == "IfcExternallyDefinedSurfaceStyle": + self.draw_externally_defined_surface_style() def draw_surface_style_shading(self): row = self.layout.row() @@ -184,6 +186,12 @@ class BIM_PT_styles(Panel): row.operator("bim.edit_surface_style", text="Save Rendering Style", icon="CHECKMARK") row.operator("bim.disable_editing_style", text="", icon="CANCEL") + def draw_externally_defined_surface_style(self): + blenderbim.bim.helper.draw_attributes(self.props.external_style_attributes, self.layout) + row = self.layout.row(align=True) + row.operator("bim.edit_surface_style", text="Save External Style", icon="CHECKMARK") + row.operator("bim.disable_editing_style", text="", icon="CANCEL") + def draw_style_ui(self, context): mat = context.material