mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix #3120. You can now assign styles to individual items.
This commit is contained in:
@@ -1053,7 +1053,6 @@ class AssignStyleToSelected(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Assign Style To Selected"
|
||||
bl_description = "Assign style to the selected objects' active representations"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
style_id: bpy.props.IntProperty(name="Style ID")
|
||||
|
||||
@classmethod
|
||||
@@ -1069,19 +1068,30 @@ class AssignStyleToSelected(bpy.types.Operator, tool.Ifc.Operator):
|
||||
return {"CANCELLED"}
|
||||
ifc_file = tool.Ifc.get()
|
||||
style = ifc_file.by_id(self.style_id)
|
||||
material = tool.Ifc.get_object(style)
|
||||
|
||||
has_items = False
|
||||
representations: dict[ifcopenshell.entity_instance, bpy.types.Object] = {}
|
||||
for obj in context.selected_objects:
|
||||
representation = tool.Geometry.get_active_representation(obj)
|
||||
if not representation:
|
||||
continue
|
||||
representation = tool.Geometry.resolve_mapped_representation(representation)
|
||||
representations.setdefault(representation, obj)
|
||||
if tool.Geometry.is_representation_item(obj):
|
||||
has_items = True
|
||||
item = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||
tool.Style.assign_style_to_representation_item(item, style)
|
||||
obj.data.materials.clear()
|
||||
obj.data.materials.append(material)
|
||||
elif representation := tool.Geometry.get_active_representation(obj):
|
||||
representation = tool.Geometry.resolve_mapped_representation(representation)
|
||||
representations.setdefault(representation, obj)
|
||||
|
||||
if not representations:
|
||||
if not has_items and not representations:
|
||||
self.report({"INFO"}, "No IFC objects with representations selected.")
|
||||
return {"FINISHED"}
|
||||
|
||||
if has_items:
|
||||
tool.Geometry.reload_representation(context.scene.BIMGeometryProperties.representation_obj)
|
||||
bpy.ops.bim.disable_editing_representation_items()
|
||||
bpy.ops.bim.enable_editing_representation_items()
|
||||
|
||||
for representation in representations:
|
||||
ifcopenshell.api.style.assign_representation_styles(
|
||||
ifc_file,
|
||||
|
||||
@@ -1513,6 +1513,10 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
verts = geometry.verts
|
||||
tool.Loader.convert_geometry_to_mesh(geometry, obj.data, verts=verts)
|
||||
|
||||
if ios_materials := list(obj.data["ios_materials"]):
|
||||
material = tool.Ifc.get_object(tool.Ifc.get().by_id(ios_materials[0]))
|
||||
obj.data.materials.append(material)
|
||||
|
||||
obj.matrix_world = rep_obj.matrix_world.copy()
|
||||
|
||||
if (is_swept_area := item.is_a("IfcSweptAreaSolid")) or item.is_a("IfcConic"):
|
||||
|
||||
Reference in New Issue
Block a user