fixed couple styles ui bugs

1) it was failing adding a new IfcSurfaceStyle if surface_style_class != Shading/Render as surface_style was not defined

2) It was never creating render material as IfcSurfaceStyleRendering class is a child of IfcSurfaceStyleShading and if statement never got to the is_a("IfcSurfaceStyleRendering") check
This commit is contained in:
Andrej730
2023-12-04 17:36:18 +05:00
parent ad934cd9a6
commit e5fa8a01b4
2 changed files with 13 additions and 4 deletions
@@ -501,6 +501,9 @@ class AddPresentationStyle(bpy.types.Operator, tool.Ifc.Operator):
props = bpy.context.scene.BIMStylesProperties
if props.style_type == "IfcSurfaceStyle":
style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=props.style_name)
# setup surface style element
surface_style = None
if props.surface_style_class in ("IfcSurfaceStyleShading", "IfcSurfaceStyleRendering"):
surface_style = ifcopenshell.api.run(
"style.add_surface_style",
@@ -518,13 +521,17 @@ class AddPresentationStyle(bpy.types.Operator, tool.Ifc.Operator):
)
if props.surface_style_class == "IfcSurfaceStyleRendering":
surface_style.ReflectanceMethod = "NOTDEFINED"
# setup blender material
material = bpy.data.materials.new(style.Name)
tool.Ifc.link(style, material)
material.use_fake_user = True
if surface_style.is_a("IfcSurfaceStyleShading"):
tool.Loader.create_surface_style_shading(material, surface_style)
elif surface_style.is_a("IfcSurfaceStyleRendering"):
tool.Loader.create_surface_style_rendering(material, surface_style)
if surface_style:
if surface_style.is_a("IfcSurfaceStyleRendering"):
tool.Loader.create_surface_style_rendering(material, surface_style)
elif surface_style.is_a("IfcSurfaceStyleShading"):
tool.Loader.create_surface_style_shading(material, surface_style)
props.is_adding = False
core.load_styles(tool.Style, style_type=props.style_type)
@@ -65,6 +65,8 @@ class BIM_PT_styles(Panel):
row.prop(self.props, "style_name", text="Name")
if self.props.style_type == "IfcSurfaceStyle":
row = box.row()
# NOTE: user must choose 1 of the style elements to create IfcSurfaceStyle
# otherwise it won't be a valid IFC
row.prop(self.props, "surface_style_class", text="Class")
if self.props.surface_style_class in ("IfcSurfaceStyleShading", "IfcSurfaceStyleRendering"):
row = box.row()