mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
WIP minor fixes to aggregate and spatial collection handling. See #1222.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell.util.schema
|
|
||||||
import blenderbim.bim.module.aggregate.assign_object as assign_object
|
import blenderbim.bim.module.aggregate.assign_object as assign_object
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.module.aggregate.data import Data
|
from blenderbim.bim.module.aggregate.data import Data
|
||||||
@@ -29,11 +28,9 @@ class AssignObject(bpy.types.Operator):
|
|||||||
Data.load(props.ifc_definition_id)
|
Data.load(props.ifc_definition_id)
|
||||||
bpy.ops.bim.disable_editing_aggregate(obj=related_object.name)
|
bpy.ops.bim.disable_editing_aggregate(obj=related_object.name)
|
||||||
|
|
||||||
declaration = IfcStore.get_schema().declaration_by_name(product.is_a())
|
related_collection = bpy.data.collections.get(related_object.name)
|
||||||
# TODO: we may not need this conditional if aggregates stop using collection instances
|
if related_collection:
|
||||||
if ifcopenshell.util.schema.is_a(declaration, "IfcSpatialElement"):
|
relating_collection = bpy.data.collections.get(relating_object.name)
|
||||||
related_collection = related_object.users_collection[0]
|
|
||||||
relating_collection = relating_object.users_collection[0]
|
|
||||||
self.remove_collection(bpy.context.scene.collection, related_collection)
|
self.remove_collection(bpy.context.scene.collection, related_collection)
|
||||||
for collection in bpy.data.collections:
|
for collection in bpy.data.collections:
|
||||||
if collection == relating_collection:
|
if collection == relating_collection:
|
||||||
|
|||||||
@@ -11,7 +11,16 @@ class BIM_PT_object_psets(Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return context.active_object is not None and hasattr(context.active_object, "BIMObjectProperties")
|
if not context.active_object:
|
||||||
|
return False
|
||||||
|
props = context.active_object.BIMObjectProperties
|
||||||
|
if not props.ifc_definition_id:
|
||||||
|
return False
|
||||||
|
if props.ifc_definition_id not in Data.products:
|
||||||
|
Data.load(props.ifc_definition_id)
|
||||||
|
if not Data.products[props.ifc_definition_id]:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
props = context.active_object.BIMObjectProperties
|
props = context.active_object.BIMObjectProperties
|
||||||
|
|||||||
@@ -110,9 +110,14 @@ class AssignClass(bpy.types.Operator):
|
|||||||
|
|
||||||
bpy.ops.bim.add_representation(obj=obj.name)
|
bpy.ops.bim.add_representation(obj=obj.name)
|
||||||
|
|
||||||
if ifcopenshell.util.schema.is_a(self.declaration, "IfcElementType"):
|
if product.is_a("IfcElementType"):
|
||||||
self.place_in_types_collection(obj)
|
self.place_in_types_collection(obj)
|
||||||
elif ifcopenshell.util.schema.is_a(self.declaration, "IfcSpatialElement") or self.ifc_class == "IfcProject":
|
elif (
|
||||||
|
product.is_a("IfcSpatialElement")
|
||||||
|
or product.is_a("IfcSpatialStructureElement")
|
||||||
|
or product.is_a("IfcProject")
|
||||||
|
or product.is_a("IfcContext")
|
||||||
|
):
|
||||||
self.place_in_spatial_collection(obj)
|
self.place_in_spatial_collection(obj)
|
||||||
else:
|
else:
|
||||||
self.assign_potential_spatial_container(obj)
|
self.assign_potential_spatial_container(obj)
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ def refreshActiveDrawingIndex(self, context):
|
|||||||
|
|
||||||
def getIfcProducts(self, context):
|
def getIfcProducts(self, context):
|
||||||
global products_enum
|
global products_enum
|
||||||
|
file = IfcStore.get_file()
|
||||||
if len(products_enum) < 1:
|
if len(products_enum) < 1:
|
||||||
products_enum.extend(
|
products_enum.extend(
|
||||||
[
|
[
|
||||||
@@ -263,6 +264,8 @@ def getIfcProducts(self, context):
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
if file.schema == "IFC2X3":
|
||||||
|
products_enum[2] = ("IfcSpatialStructureElement", "IfcSpatialStructureElement", "")
|
||||||
return products_enum
|
return products_enum
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user