mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
WIP purge old aggregate system. See #1222.
This commit is contained in:
@@ -90,10 +90,6 @@ if bpy is not None:
|
||||
operator.SelectGlobalId,
|
||||
operator.SelectAttribute,
|
||||
operator.SelectPset,
|
||||
operator.CreateAggregate,
|
||||
operator.EditAggregate,
|
||||
operator.SaveAggregate,
|
||||
operator.ExplodeAggregate,
|
||||
operator.LoadClassification,
|
||||
operator.AddClassification,
|
||||
operator.RemoveClassification,
|
||||
|
||||
@@ -1261,106 +1261,6 @@ class SelectSchemaDir(bpy.types.Operator):
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class CreateAggregate(bpy.types.Operator):
|
||||
bl_idname = "bim.create_aggregate"
|
||||
bl_label = "Create Aggregate"
|
||||
|
||||
def execute(self, context):
|
||||
spatial_container = None
|
||||
for obj in bpy.context.selected_objects:
|
||||
if obj.instance_collection:
|
||||
return {"FINISHED"}
|
||||
for collection in obj.users_collection:
|
||||
if "IfcRelAggregates" in collection.name:
|
||||
return {"FINISHED"}
|
||||
elif collection.name[0:3] == "Ifc":
|
||||
spatial_container = collection
|
||||
if not spatial_container:
|
||||
return {"FINISHED"}
|
||||
|
||||
aggregate = bpy.data.collections.new(
|
||||
"IfcRelAggregates/{}".format(bpy.context.scene.BIMProperties.aggregate_class)
|
||||
)
|
||||
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
|
||||
if not [c for c in project.children if "Aggregates" in c.name]:
|
||||
aggregates = bpy.data.collections.new("Aggregates")
|
||||
project.collection.children.link(aggregates)
|
||||
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
|
||||
aggregate_collection.collection.children.link(aggregate)
|
||||
break
|
||||
break
|
||||
for obj in bpy.context.selected_objects:
|
||||
for collection in obj.users_collection:
|
||||
collection.objects.unlink(obj)
|
||||
aggregate.objects.link(obj)
|
||||
|
||||
instance = bpy.data.objects.new(
|
||||
"{}/{}".format(
|
||||
bpy.context.scene.BIMProperties.aggregate_class, bpy.context.scene.BIMProperties.aggregate_name
|
||||
),
|
||||
None,
|
||||
)
|
||||
instance.instance_type = "COLLECTION"
|
||||
instance.instance_collection = aggregate
|
||||
spatial_container.objects.link(instance)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class EditAggregate(bpy.types.Operator):
|
||||
bl_idname = "bim.edit_aggregate"
|
||||
bl_label = "Edit Aggregate"
|
||||
|
||||
def execute(self, context):
|
||||
obj = bpy.context.active_object
|
||||
if obj.instance_type != "COLLECTION" or "IfcRelAggregates" not in obj.instance_collection.name:
|
||||
return {"FINISHED"}
|
||||
bpy.context.view_layer.objects[obj.name].hide_viewport = True
|
||||
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
|
||||
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
|
||||
aggregate_collection.hide_viewport = False
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SaveAggregate(bpy.types.Operator):
|
||||
bl_idname = "bim.save_aggregate"
|
||||
bl_label = "Save Aggregate"
|
||||
|
||||
def execute(self, context):
|
||||
obj = bpy.context.active_object
|
||||
aggregate = None
|
||||
names = [c.name for c in obj.users_collection]
|
||||
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
|
||||
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
|
||||
aggregate_collection.hide_viewport = True
|
||||
for collection in [c for c in aggregate_collection.children if c.name in names]:
|
||||
aggregate = collection.collection
|
||||
break
|
||||
if not aggregate:
|
||||
return {"FINISHED"}
|
||||
for obj in bpy.context.view_layer.objects:
|
||||
if obj.instance_collection == aggregate:
|
||||
obj.hide_viewport = False
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ExplodeAggregate(bpy.types.Operator):
|
||||
bl_idname = "bim.explode_aggregate"
|
||||
bl_label = "Explode Aggregate"
|
||||
|
||||
def execute(self, context):
|
||||
obj = bpy.context.active_object
|
||||
if obj.instance_type != "COLLECTION" or "IfcRelAggregates" not in obj.instance_collection.name:
|
||||
return {"FINISHED"}
|
||||
aggregate_collection = bpy.data.collections.get(obj.instance_collection.name)
|
||||
spatial_collection = obj.users_collection[0]
|
||||
for part in aggregate_collection.objects:
|
||||
spatial_collection.objects.link(part)
|
||||
aggregate_collection.objects.unlink(part)
|
||||
bpy.data.objects.remove(obj, do_unlink=True)
|
||||
bpy.data.collections.remove(aggregate_collection, do_unlink=True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class LoadClassification(bpy.types.Operator):
|
||||
bl_idname = "bim.load_classification"
|
||||
bl_label = "Load Classification"
|
||||
|
||||
@@ -1075,8 +1075,6 @@ class BIMProperties(PropertyGroup):
|
||||
diff_old_file: StringProperty(default="", name="Diff Old IFC File")
|
||||
diff_new_file: StringProperty(default="", name="Diff New IFC File")
|
||||
diff_relationships: StringProperty(default="", name="Diff Relationships")
|
||||
aggregate_class: EnumProperty(items=getIfcClasses, name="Aggregate Class")
|
||||
aggregate_name: StringProperty(name="Aggregate Name")
|
||||
classification: EnumProperty(items=getClassifications, name="Classification", update=refreshReferences)
|
||||
active_classification_name: StringProperty(name="Active Classification Name")
|
||||
classifications: CollectionProperty(name="Classifications", type=Classification)
|
||||
|
||||
@@ -771,20 +771,6 @@ class BIM_PT_bim(Panel):
|
||||
row.operator("bim.select_class")
|
||||
row.operator("bim.select_type")
|
||||
|
||||
layout.label(text="Aggregates:")
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, "aggregate_class")
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, "aggregate_name")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.create_aggregate")
|
||||
row.operator("bim.explode_aggregate")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.edit_aggregate")
|
||||
row.operator("bim.save_aggregate")
|
||||
|
||||
|
||||
class BIM_PT_search(Panel):
|
||||
bl_label = "IFC Search"
|
||||
|
||||
Reference in New Issue
Block a user