WIP assigning a class also assigns the spatial container if possible. See #1222.

This commit is contained in:
Dion Moult
2021-01-04 16:23:36 +11:00
parent 23a66b3a72
commit d4a219e54f
4 changed files with 27 additions and 8 deletions
@@ -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_representation as assign_representation
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
@@ -136,8 +137,26 @@ class AssignClass(bpy.types.Operator):
)
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.BIMObjectProperties.ifc_definition_id = int(result.id())
obj.BIMObjectProperties.ifc_definition_id = int(product.id())
if bpy.context.scene.BIMProperties.ifc_product == "IfcElementType":
self.place_in_types_collection(obj)
return {"FINISHED"}
@@ -15,7 +15,7 @@ class Usecase:
contained_in_structure = self.settings["product"].ContainedInStructure
contains_elements = self.settings["relating_structure"].ContainsElements
if contained_in_structure == contains_elements:
if contains_elements and contained_in_structure == contains_elements:
return
if contained_in_structure:
@@ -10,9 +10,8 @@ class Data:
if not file:
return
product = file.by_id(product_id)
element = product.ContainedInStructure[0].RelatingStructure if product.ContainedInStructure else None
cls.products[product_id] = {
"type": element.is_a() if element else None,
"Name": element.Name if element else None,
"id": int(element.id()) if element else None
}
if product.ContainedInStructure:
structure = product.ContainedInStructure[0].RelatingStructure
cls.products[product_id] = {"type": structure.is_a(), "Name": structure.Name, "id": int(structure.id())}
else:
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(
bpy.data.objects.get(collection.name).BIMObjectProperties.ifc_definition_id
)
break
if not relating_structure:
return {"FINISHED"}
usecase = assign_container.Usecase(