mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Openings locations are fixed relative to slab profile editing
This commit is contained in:
@@ -281,7 +281,11 @@ class IfcStore:
|
|||||||
if existing_obj == obj:
|
if existing_obj == obj:
|
||||||
return
|
return
|
||||||
elif existing_obj:
|
elif existing_obj:
|
||||||
IfcStore.unlink_element(obj=existing_obj)
|
try:
|
||||||
|
existing_obj.name
|
||||||
|
IfcStore.unlink_element(obj=existing_obj)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
IfcStore.id_map[element.id()] = obj
|
IfcStore.id_map[element.id()] = obj
|
||||||
if hasattr(element, "GlobalId"):
|
if hasattr(element, "GlobalId"):
|
||||||
IfcStore.guid_map[element.GlobalId] = obj
|
IfcStore.guid_map[element.GlobalId] = obj
|
||||||
|
|||||||
@@ -165,11 +165,14 @@ class DumbSlabGenerator:
|
|||||||
obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(self.relating_type, ifc_class), mesh)
|
obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(self.relating_type, ifc_class), mesh)
|
||||||
|
|
||||||
if link_to_scene:
|
if link_to_scene:
|
||||||
obj.location = self.location
|
matrix_world = Matrix()
|
||||||
|
matrix_world.col[3] = self.location.to_4d()
|
||||||
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
||||||
obj.location[2] = self.collection_obj.location[2] - self.depth
|
matrix_world[2][3] = self.collection_obj.location[2] - self.depth
|
||||||
else:
|
else:
|
||||||
obj.location[2] -= self.depth
|
matrix_world[2][3] -= self.depth
|
||||||
|
obj.matrix_world = matrix_world
|
||||||
|
bpy.context.view_layer.update()
|
||||||
self.collection.objects.link(obj)
|
self.collection.objects.link(obj)
|
||||||
|
|
||||||
element = blenderbim.core.root.assign_class(
|
element = blenderbim.core.root.assign_class(
|
||||||
@@ -183,6 +186,7 @@ class DumbSlabGenerator:
|
|||||||
)
|
)
|
||||||
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=self.relating_type)
|
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=self.relating_type)
|
||||||
|
|
||||||
|
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||||
representation = ifcopenshell.api.run(
|
representation = ifcopenshell.api.run(
|
||||||
"geometry.add_slab_representation", tool.Ifc.get(), context=self.body_context, depth=self.depth
|
"geometry.add_slab_representation", tool.Ifc.get(), context=self.body_context, depth=self.depth
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -532,10 +532,11 @@ class DumbWallGenerator:
|
|||||||
mesh = bpy.data.meshes.new("Dummy")
|
mesh = bpy.data.meshes.new("Dummy")
|
||||||
obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(self.relating_type, ifc_class), mesh)
|
obj = bpy.data.objects.new(tool.Model.generate_occurrence_name(self.relating_type, ifc_class), mesh)
|
||||||
if link_to_scene:
|
if link_to_scene:
|
||||||
obj.location = self.location
|
matrix_world = Matrix.Rotation(self.rotation, 4, "Z")
|
||||||
obj.rotation_euler[2] = self.rotation
|
matrix_world.col[3] = self.location.to_4d()
|
||||||
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
||||||
obj.location[2] = self.collection_obj.location[2]
|
matrix_world[2][3] = self.collection_obj.location[2]
|
||||||
|
obj.matrix_world = matrix_world
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
self.collection.objects.link(obj)
|
self.collection.objects.link(obj)
|
||||||
|
|
||||||
@@ -559,6 +560,7 @@ class DumbWallGenerator:
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=representation
|
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=representation
|
||||||
)
|
)
|
||||||
|
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||||
representation = ifcopenshell.api.run(
|
representation = ifcopenshell.api.run(
|
||||||
"geometry.add_wall_representation",
|
"geometry.add_wall_representation",
|
||||||
tool.Ifc.get(),
|
tool.Ifc.get(),
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if not obj1.data or not hasattr(obj1.data, "BIMMeshProperties"):
|
if not obj1.data or not hasattr(obj1.data, "BIMMeshProperties"):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
if tool.Ifc.is_moved(obj1):
|
||||||
|
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj1)
|
||||||
|
|
||||||
has_visible_openings = False
|
has_visible_openings = False
|
||||||
for opening in [r.RelatedOpeningElement for r in element1.HasOpenings]:
|
for opening in [r.RelatedOpeningElement for r in element1.HasOpenings]:
|
||||||
if tool.Ifc.get_object(opening):
|
if tool.Ifc.get_object(opening):
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Collector(blenderbim.core.tool.Collector):
|
|||||||
# This is the reverse of assign. It reads the Blender collection and figures out its IFC hierarchy
|
# This is the reverse of assign. It reads the Blender collection and figures out its IFC hierarchy
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|
||||||
if element.is_a("IfcProject") or element.is_a("IfcGridAxis"):
|
if element.is_a("IfcProject") or element.is_a("IfcGridAxis") or element.is_a("IfcOpeningElement"):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not obj.users_collection:
|
if not obj.users_collection:
|
||||||
|
|||||||
@@ -306,3 +306,12 @@ class TestSync(NewFile):
|
|||||||
col.objects.link(obj)
|
col.objects.link(obj)
|
||||||
subject.sync(obj)
|
subject.sync(obj)
|
||||||
assert ifcopenshell.util.element.get_aggregate(element).is_a("IfcBuilding")
|
assert ifcopenshell.util.element.get_aggregate(element).is_a("IfcBuilding")
|
||||||
|
|
||||||
|
def test_openings_are_never_contained(self):
|
||||||
|
bpy.ops.bim.create_project()
|
||||||
|
obj = bpy.data.objects.new("Object", None)
|
||||||
|
element = tool.Ifc.get().createIfcOpeningElement()
|
||||||
|
tool.Ifc.link(element, obj)
|
||||||
|
bpy.data.collections.get("IfcSite/My Site").objects.link(obj)
|
||||||
|
subject.sync(obj)
|
||||||
|
assert ifcopenshell.util.element.get_container(element) is None
|
||||||
|
|||||||
Reference in New Issue
Block a user