mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
Support editing IfcSurfaceStyleRefraction in UI
This commit is contained in:
@@ -505,8 +505,8 @@ class EnableEditingSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
tool.Style.set_surface_style_props()
|
tool.Style.set_surface_style_props()
|
||||||
|
|
||||||
surface_style = tool.Style.get_style_elements(style).get(self.ifc_class, None)
|
surface_style = tool.Style.get_style_elements(style).get(self.ifc_class, None)
|
||||||
if self.ifc_class == "IfcExternallyDefinedSurfaceStyle":
|
attributes = tool.Style.get_style_ui_props_attributes(self.ifc_class)
|
||||||
attributes = props.external_style_attributes
|
if attributes is not None:
|
||||||
attributes.clear()
|
attributes.clear()
|
||||||
blenderbim.bim.helper.import_attributes2(surface_style or self.ifc_class, attributes)
|
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},
|
attributes={"Textures": textures},
|
||||||
)
|
)
|
||||||
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
||||||
elif self.surface_style.is_a() == "IfcExternallyDefinedSurfaceStyle":
|
else:
|
||||||
ifcopenshell.api.run(
|
attributes = tool.Style.get_style_ui_props_attributes(self.surface_style.is_a())
|
||||||
"style.edit_surface_style",
|
if attributes is not None:
|
||||||
tool.Ifc.get(),
|
ifcopenshell.api.run(
|
||||||
style=self.surface_style,
|
"style.edit_surface_style",
|
||||||
attributes=blenderbim.bim.helper.export_attributes(self.props.external_style_attributes),
|
tool.Ifc.get(),
|
||||||
)
|
style=self.surface_style,
|
||||||
|
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
||||||
|
)
|
||||||
|
|
||||||
def add_new_style(self):
|
def add_new_style(self):
|
||||||
material = tool.Ifc.get_object(self.style)
|
material = tool.Ifc.get_object(self.style)
|
||||||
@@ -623,14 +625,16 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
attributes={"Textures": textures},
|
attributes={"Textures": textures},
|
||||||
)
|
)
|
||||||
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
||||||
elif self.props.is_editing_class == "IfcExternallyDefinedSurfaceStyle":
|
else:
|
||||||
surface_style = ifcopenshell.api.run(
|
attributes = tool.Style.get_style_ui_props_attributes(self.props.is_editing_class)
|
||||||
"style.add_surface_style",
|
if attributes is not None:
|
||||||
tool.Ifc.get(),
|
surface_style = ifcopenshell.api.run(
|
||||||
style=self.style,
|
"style.add_surface_style",
|
||||||
ifc_class="IfcExternallyDefinedSurfaceStyle",
|
tool.Ifc.get(),
|
||||||
attributes=blenderbim.bim.helper.export_attributes(self.props.external_style_attributes),
|
style=self.style,
|
||||||
)
|
ifc_class=self.props.is_editing_class,
|
||||||
|
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
||||||
|
)
|
||||||
|
|
||||||
def get_shading_attributes(self):
|
def get_shading_attributes(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class BIMStylesProperties(PropertyGroup):
|
|||||||
is_editing_class: StringProperty(name="Is Editing Class")
|
is_editing_class: StringProperty(name="Is Editing Class")
|
||||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||||
external_style_attributes: CollectionProperty(name="External Style 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_type: EnumProperty(items=get_style_types, default=2, name="Style Type")
|
||||||
style_name: StringProperty(name="Style Name")
|
style_name: StringProperty(name="Style Name")
|
||||||
surface_style_class: EnumProperty(
|
surface_style_class: EnumProperty(
|
||||||
|
|||||||
@@ -134,8 +134,10 @@ class BIM_PT_styles(Panel):
|
|||||||
self.draw_externally_defined_surface_style()
|
self.draw_externally_defined_surface_style()
|
||||||
elif self.props.is_editing_class == "IfcSurfaceStyleWithTextures":
|
elif self.props.is_editing_class == "IfcSurfaceStyleWithTextures":
|
||||||
self.draw_surface_style_with_textures()
|
self.draw_surface_style_with_textures()
|
||||||
|
elif self.props.is_editing_class == "IfcSurfaceStyleRefraction":
|
||||||
|
self.draw_refraction_surface_style()
|
||||||
else:
|
else:
|
||||||
# TODO: UI Lighting, Refract
|
# TODO: UI Lighting
|
||||||
self.layout.label(text=f"{self.props.is_editing_class} UI is not yet supported.")
|
self.layout.label(text=f"{self.props.is_editing_class} UI is not yet supported.")
|
||||||
|
|
||||||
def draw_surface_style_shading(self):
|
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.edit_surface_style", text="Save External Style", icon="CHECKMARK")
|
||||||
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
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):
|
class BIM_PT_style(MaterialButtonsPanel, Panel):
|
||||||
bl_label = "Style"
|
bl_label = "Style"
|
||||||
|
|||||||
@@ -453,6 +453,14 @@ class Style(blenderbim.core.tool.Style):
|
|||||||
results.append(uv_map)
|
results.append(uv_map)
|
||||||
return results
|
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
|
@classmethod
|
||||||
def import_presentation_styles(cls, style_type):
|
def import_presentation_styles(cls, style_type):
|
||||||
color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)
|
color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)
|
||||||
|
|||||||
Reference in New Issue
Block a user