mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Adding / editing shading / rendering styles in the style manager now updates Blender materials
This commit is contained in:
@@ -477,6 +477,13 @@ class AddPresentationStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
)
|
)
|
||||||
if props.surface_style_class == "IfcSurfaceStyleRendering":
|
if props.surface_style_class == "IfcSurfaceStyleRendering":
|
||||||
surface_style.ReflectanceMethod = "NOTDEFINED"
|
surface_style.ReflectanceMethod = "NOTDEFINED"
|
||||||
|
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)
|
||||||
props.is_adding = False
|
props.is_adding = False
|
||||||
core.load_styles(tool.Style, style_type=props.style_type)
|
core.load_styles(tool.Style, style_type=props.style_type)
|
||||||
|
|
||||||
@@ -580,6 +587,7 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
core.load_styles(tool.Style, style_type=self.props.style_type)
|
core.load_styles(tool.Style, style_type=self.props.style_type)
|
||||||
|
|
||||||
def edit_existing_style(self):
|
def edit_existing_style(self):
|
||||||
|
material = tool.Ifc.get_object(self.style)
|
||||||
if self.surface_style.is_a() == "IfcSurfaceStyleShading":
|
if self.surface_style.is_a() == "IfcSurfaceStyleShading":
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"style.edit_surface_style",
|
"style.edit_surface_style",
|
||||||
@@ -590,6 +598,7 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
"Transparency": self.props.transparency or None,
|
"Transparency": self.props.transparency or None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
tool.Loader.create_surface_style_shading(material, self.surface_style)
|
||||||
elif self.surface_style.is_a() == "IfcSurfaceStyleRendering":
|
elif self.surface_style.is_a() == "IfcSurfaceStyleRendering":
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"style.edit_surface_style",
|
"style.edit_surface_style",
|
||||||
@@ -597,24 +606,28 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
style=self.surface_style,
|
style=self.surface_style,
|
||||||
attributes=self.get_rendering_attributes(),
|
attributes=self.get_rendering_attributes(),
|
||||||
)
|
)
|
||||||
|
tool.Loader.create_surface_style_rendering(material, self.surface_style)
|
||||||
|
|
||||||
def add_new_style(self):
|
def add_new_style(self):
|
||||||
|
material = tool.Ifc.get_object(self.style)
|
||||||
if self.props.is_editing_class == "IfcSurfaceStyleShading":
|
if self.props.is_editing_class == "IfcSurfaceStyleShading":
|
||||||
ifcopenshell.api.run(
|
surface_style = ifcopenshell.api.run(
|
||||||
"style.add_surface_style",
|
"style.add_surface_style",
|
||||||
tool.Ifc.get(),
|
tool.Ifc.get(),
|
||||||
style=self.style,
|
style=self.style,
|
||||||
ifc_class="IfcSurfaceStyleShading",
|
ifc_class="IfcSurfaceStyleShading",
|
||||||
attributes=self.get_shading_attributes(),
|
attributes=self.get_shading_attributes(),
|
||||||
)
|
)
|
||||||
|
tool.Loader.create_surface_style_shading(material, surface_style)
|
||||||
elif self.props.is_editing_class == "IfcSurfaceStyleRendering":
|
elif self.props.is_editing_class == "IfcSurfaceStyleRendering":
|
||||||
ifcopenshell.api.run(
|
surface_style = ifcopenshell.api.run(
|
||||||
"style.add_surface_style",
|
"style.add_surface_style",
|
||||||
tool.Ifc.get(),
|
tool.Ifc.get(),
|
||||||
style=self.style,
|
style=self.style,
|
||||||
ifc_class="IfcSurfaceStyleRendering",
|
ifc_class="IfcSurfaceStyleRendering",
|
||||||
attributes=self.get_rendering_attributes(),
|
attributes=self.get_rendering_attributes(),
|
||||||
)
|
)
|
||||||
|
tool.Loader.create_surface_style_rendering(material, surface_style)
|
||||||
|
|
||||||
def get_shading_attributes(self):
|
def get_shading_attributes(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class Loader(blenderbim.core.tool.Loader):
|
|||||||
if transparency := surface_style.get("Transparency", None):
|
if transparency := surface_style.get("Transparency", None):
|
||||||
alpha = 1 - transparency
|
alpha = 1 - transparency
|
||||||
blender_material.diffuse_color = surface_style["SurfaceColour"][:3] + (alpha,)
|
blender_material.diffuse_color = surface_style["SurfaceColour"][:3] + (alpha,)
|
||||||
|
blender_material.use_nodes = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def restart_material_node_tree(cls, blender_material):
|
def restart_material_node_tree(cls, blender_material):
|
||||||
|
|||||||
Reference in New Issue
Block a user