Support editing IfcSurfaceStyleRefraction in UI

This commit is contained in:
Andrej730
2023-12-13 15:16:52 +05:00
parent f1a4ed702b
commit f6fab30d0a
4 changed files with 39 additions and 18 deletions
@@ -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 {
@@ -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(
@@ -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"
+8
View File
@@ -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)