mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Windows now move with openings and walls when toggled.
This commit is contained in:
@@ -113,6 +113,8 @@ class AddElementOpening(bpy.types.Operator):
|
|||||||
opening.name = "Opening"
|
opening.name = "Opening"
|
||||||
|
|
||||||
bpy.ops.bim.add_opening(opening=opening.name, obj=voided_obj.name)
|
bpy.ops.bim.add_opening(opening=opening.name, obj=voided_obj.name)
|
||||||
|
if filling_obj:
|
||||||
|
bpy.ops.bim.add_filling(opening=opening.name, obj=filling_obj.name)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def get_voided_building_element(self, context):
|
def get_voided_building_element(self, context):
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
@@ -19,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.representation
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from ifcopenshell.api.void.data import Data
|
from ifcopenshell.api.void.data import Data
|
||||||
from ifcopenshell.api.context.data import Data as ContextData
|
from ifcopenshell.api.context.data import Data as ContextData
|
||||||
@@ -35,23 +35,16 @@ class AddOpening(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.scene.objects.get(self.obj, context.active_object)
|
obj = context.scene.objects.get(self.obj, context.active_object)
|
||||||
opening = context.scene.objects.get(self.opening)
|
opening = bpy.data.objects.get(self.opening)
|
||||||
if opening is None:
|
if opening is None:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
opening.display_type = "WIRE"
|
opening.display_type = "WIRE"
|
||||||
if not opening.BIMObjectProperties.ifc_definition_id:
|
if not opening.BIMObjectProperties.ifc_definition_id:
|
||||||
body_context_id = None
|
body_context = ifcopenshell.util.representation.get_context(IfcStore.get_file(), "Model", "Body")
|
||||||
if not ContextData.is_loaded:
|
if not body_context:
|
||||||
ContextData.load(IfcStore.get_file())
|
|
||||||
for context in ContextData.contexts.values():
|
|
||||||
for subcontext_id, subcontext in context["HasSubContexts"].items():
|
|
||||||
if subcontext["ContextType"] == "Model" and subcontext["ContextIdentifier"] == "Body":
|
|
||||||
body_context_id = subcontext_id
|
|
||||||
break
|
|
||||||
if not body_context_id:
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
bpy.ops.bim.assign_class(obj=opening.name, ifc_class="IfcOpeningElement", context_id=body_context_id)
|
bpy.ops.bim.assign_class(obj=opening.name, ifc_class="IfcOpeningElement", context_id=body_context.id())
|
||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
element_id = obj.BIMObjectProperties.ifc_definition_id
|
element_id = obj.BIMObjectProperties.ifc_definition_id
|
||||||
@@ -120,10 +113,10 @@ class AddFilling(bpy.types.Operator):
|
|||||||
return IfcStore.execute_ifc_operator(self, context)
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.scene.objects.get(self.obj, context.active_object)
|
obj = context.scene.objects.get(self.obj, context.active_object)
|
||||||
opening = context.scene.objects.get(self.opening, context.scene.VoidProperties.desired_opening)
|
opening = context.scene.objects.get(self.opening, context.scene.VoidProperties.desired_opening)
|
||||||
if opening is None:
|
if opening is None:
|
||||||
return {'FINISHED'}
|
return {"FINISHED"}
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
element_id = obj.BIMObjectProperties.ifc_definition_id
|
element_id = obj.BIMObjectProperties.ifc_definition_id
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
@@ -203,15 +196,18 @@ class ToggleDecompositionParenting(bpy.types.Operator):
|
|||||||
def load_decompositions(self, parent_obj):
|
def load_decompositions(self, parent_obj):
|
||||||
element = self.file.by_id(parent_obj.BIMObjectProperties.ifc_definition_id)
|
element = self.file.by_id(parent_obj.BIMObjectProperties.ifc_definition_id)
|
||||||
for rel in self.file.get_inverse(element):
|
for rel in self.file.get_inverse(element):
|
||||||
if not (rel.is_a("IfcRelDecomposes") or rel.is_a("IfcRelFillsElement")):
|
if rel.is_a("IfcRelDecomposes"):
|
||||||
continue
|
if rel[4] != element:
|
||||||
if rel[4] != element:
|
continue
|
||||||
continue
|
if isinstance(rel[5], tuple):
|
||||||
if isinstance(rel[5], tuple):
|
for related_object in rel[5]:
|
||||||
for related_object in rel[5]:
|
self.add_decomposition(parent_obj, related_object)
|
||||||
self.add_decomposition(parent_obj, related_object)
|
else:
|
||||||
else:
|
self.add_decomposition(parent_obj, rel[5])
|
||||||
self.add_decomposition(parent_obj, rel[5])
|
elif rel.is_a("IfcRelFillsElement"):
|
||||||
|
if rel.RelatingOpeningElement != element:
|
||||||
|
continue
|
||||||
|
self.add_decomposition(parent_obj, rel.RelatedBuildingElement)
|
||||||
|
|
||||||
def add_decomposition(self, parent_obj, child_element):
|
def add_decomposition(self, parent_obj, child_element):
|
||||||
child_obj = IfcStore.get_element(child_element.id())
|
child_obj = IfcStore.get_element(child_element.id())
|
||||||
|
|||||||
Reference in New Issue
Block a user