Skip to content

Commit e5fa8a0

Browse files
committed
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
1 parent ad934cd commit e5fa8a0

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/blenderbim/blenderbim/bim/module/style/operator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ def _execute(self, context):
501501
props = bpy.context.scene.BIMStylesProperties
502502
if props.style_type == "IfcSurfaceStyle":
503503
style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=props.style_name)
504+
505+
# setup surface style element
506+
surface_style = None
504507
if props.surface_style_class in ("IfcSurfaceStyleShading", "IfcSurfaceStyleRendering"):
505508
surface_style = ifcopenshell.api.run(
506509
"style.add_surface_style",
@@ -518,13 +521,17 @@ def _execute(self, context):
518521
)
519522
if props.surface_style_class == "IfcSurfaceStyleRendering":
520523
surface_style.ReflectanceMethod = "NOTDEFINED"
524+
525+
# setup blender material
521526
material = bpy.data.materials.new(style.Name)
522527
tool.Ifc.link(style, material)
523528
material.use_fake_user = True
524-
if surface_style.is_a("IfcSurfaceStyleShading"):
525-
tool.Loader.create_surface_style_shading(material, surface_style)
526-
elif surface_style.is_a("IfcSurfaceStyleRendering"):
527-
tool.Loader.create_surface_style_rendering(material, surface_style)
529+
if surface_style:
530+
if surface_style.is_a("IfcSurfaceStyleRendering"):
531+
tool.Loader.create_surface_style_rendering(material, surface_style)
532+
elif surface_style.is_a("IfcSurfaceStyleShading"):
533+
tool.Loader.create_surface_style_shading(material, surface_style)
534+
528535
props.is_adding = False
529536
core.load_styles(tool.Style, style_type=props.style_type)
530537

src/blenderbim/blenderbim/bim/module/style/ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def draw(self, context):
6565
row.prop(self.props, "style_name", text="Name")
6666
if self.props.style_type == "IfcSurfaceStyle":
6767
row = box.row()
68+
# NOTE: user must choose 1 of the style elements to create IfcSurfaceStyle
69+
# otherwise it won't be a valid IFC
6870
row.prop(self.props, "surface_style_class", text="Class")
6971
if self.props.surface_style_class in ("IfcSurfaceStyleShading", "IfcSurfaceStyleRendering"):
7072
row = box.row()

0 commit comments

Comments
 (0)