mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
New style manager supports basic editing of externally defined surface styles
This commit is contained in:
@@ -550,9 +550,19 @@ class EnableEditingSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
props.is_specular_highlight_null = True
|
props.is_specular_highlight_null = True
|
||||||
|
|
||||||
props.reflectance_method = surface_style.ReflectanceMethod
|
props.reflectance_method = surface_style.ReflectanceMethod
|
||||||
elif shading:
|
elif self.ifc_class == "IfcExternallyDefinedSurfaceStyle":
|
||||||
props.surface_colour = color_to_tuple(shading.SurfaceColour)
|
attributes = props.external_style_attributes
|
||||||
props.transparency = shading.Transparency or 0.0
|
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_style = self.style
|
||||||
props.is_editing_class = self.ifc_class
|
props.is_editing_class = self.ifc_class
|
||||||
@@ -607,6 +617,13 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
attributes=self.get_rendering_attributes(),
|
attributes=self.get_rendering_attributes(),
|
||||||
)
|
)
|
||||||
tool.Loader.create_surface_style_rendering(material, self.surface_style)
|
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):
|
def add_new_style(self):
|
||||||
material = tool.Ifc.get_object(self.style)
|
material = tool.Ifc.get_object(self.style)
|
||||||
@@ -628,6 +645,14 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
attributes=self.get_rendering_attributes(),
|
attributes=self.get_rendering_attributes(),
|
||||||
)
|
)
|
||||||
tool.Loader.create_surface_style_rendering(material, surface_style)
|
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):
|
def get_shading_attributes(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class BIMStylesProperties(PropertyGroup):
|
|||||||
is_editing_style: IntProperty(name="Is Editing Style")
|
is_editing_style: IntProperty(name="Is Editing Style")
|
||||||
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)
|
||||||
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(
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ class BIM_PT_styles(Panel):
|
|||||||
self.draw_surface_style_shading()
|
self.draw_surface_style_shading()
|
||||||
elif self.props.is_editing_class == "IfcSurfaceStyleRendering":
|
elif self.props.is_editing_class == "IfcSurfaceStyleRendering":
|
||||||
self.draw_surface_style_rendering()
|
self.draw_surface_style_rendering()
|
||||||
|
elif self.props.is_editing_class == "IfcExternallyDefinedSurfaceStyle":
|
||||||
|
self.draw_externally_defined_surface_style()
|
||||||
|
|
||||||
def draw_surface_style_shading(self):
|
def draw_surface_style_shading(self):
|
||||||
row = self.layout.row()
|
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.edit_surface_style", text="Save Rendering Style", icon="CHECKMARK")
|
||||||
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
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):
|
def draw_style_ui(self, context):
|
||||||
mat = context.material
|
mat = context.material
|
||||||
|
|||||||
Reference in New Issue
Block a user