mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
WIP assigning a class also assigns the spatial container if possible. See #1222.
This commit is contained in:
@@ -8,6 +8,7 @@ import blenderbim.bim.module.geometry.add_representation as add_representation
|
|||||||
import blenderbim.bim.module.geometry.assign_styles as assign_styles
|
import blenderbim.bim.module.geometry.assign_styles as assign_styles
|
||||||
import blenderbim.bim.module.geometry.assign_representation as assign_representation
|
import blenderbim.bim.module.geometry.assign_representation as assign_representation
|
||||||
import blenderbim.bim.module.geometry.add_object_placement as add_object_placement
|
import blenderbim.bim.module.geometry.add_object_placement as add_object_placement
|
||||||
|
import blenderbim.bim.module.spatial.assign_container as assign_container
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
|
||||||
|
|
||||||
@@ -136,8 +137,26 @@ class AssignClass(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
usecase.execute()
|
usecase.execute()
|
||||||
|
|
||||||
|
relating_structure = None
|
||||||
|
for collection in obj.users_collection:
|
||||||
|
if "Ifc" in collection.name:
|
||||||
|
relating_structure = self.file.by_id(
|
||||||
|
bpy.data.objects.get(collection.name).BIMObjectProperties.ifc_definition_id
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
if relating_structure:
|
||||||
|
usecase = assign_container.Usecase(
|
||||||
|
self.file,
|
||||||
|
{
|
||||||
|
"product": product,
|
||||||
|
"relating_structure": relating_structure,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
usecase.execute()
|
||||||
|
|
||||||
obj.name = "{}/{}".format(bpy.context.scene.BIMProperties.ifc_class, obj.name)
|
obj.name = "{}/{}".format(bpy.context.scene.BIMProperties.ifc_class, obj.name)
|
||||||
obj.BIMObjectProperties.ifc_definition_id = int(result.id())
|
obj.BIMObjectProperties.ifc_definition_id = int(product.id())
|
||||||
if bpy.context.scene.BIMProperties.ifc_product == "IfcElementType":
|
if bpy.context.scene.BIMProperties.ifc_product == "IfcElementType":
|
||||||
self.place_in_types_collection(obj)
|
self.place_in_types_collection(obj)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Usecase:
|
|||||||
contained_in_structure = self.settings["product"].ContainedInStructure
|
contained_in_structure = self.settings["product"].ContainedInStructure
|
||||||
contains_elements = self.settings["relating_structure"].ContainsElements
|
contains_elements = self.settings["relating_structure"].ContainsElements
|
||||||
|
|
||||||
if contained_in_structure == contains_elements:
|
if contains_elements and contained_in_structure == contains_elements:
|
||||||
return
|
return
|
||||||
|
|
||||||
if contained_in_structure:
|
if contained_in_structure:
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ class Data:
|
|||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
product = file.by_id(product_id)
|
product = file.by_id(product_id)
|
||||||
element = product.ContainedInStructure[0].RelatingStructure if product.ContainedInStructure else None
|
if product.ContainedInStructure:
|
||||||
cls.products[product_id] = {
|
structure = product.ContainedInStructure[0].RelatingStructure
|
||||||
"type": element.is_a() if element else None,
|
cls.products[product_id] = {"type": structure.is_a(), "Name": structure.Name, "id": int(structure.id())}
|
||||||
"Name": element.Name if element else None,
|
else:
|
||||||
"id": int(element.id()) if element else None
|
cls.products[product_id] = {"type": None, "Name": None, "id": None}
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class AssignContainer(bpy.types.Operator):
|
|||||||
relating_structure = self.file.by_id(
|
relating_structure = self.file.by_id(
|
||||||
bpy.data.objects.get(collection.name).BIMObjectProperties.ifc_definition_id
|
bpy.data.objects.get(collection.name).BIMObjectProperties.ifc_definition_id
|
||||||
)
|
)
|
||||||
|
break
|
||||||
if not relating_structure:
|
if not relating_structure:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
usecase = assign_container.Usecase(
|
usecase = assign_container.Usecase(
|
||||||
|
|||||||
Reference in New Issue
Block a user