New style manager supports basic editing of externally defined surface styles

This commit is contained in:
Dion Moult
2023-11-23 13:17:33 +11:00
parent e3742cefb0
commit f1b59ee583
3 changed files with 37 additions and 3 deletions
@@ -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 {
@@ -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(
@@ -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