mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 16:43:00 +00:00
Model module walls/slabs/products/mep now use the default container too.
This commit is contained in:
@@ -243,7 +243,6 @@ class MEPGenerator:
|
|||||||
|
|
||||||
def setup_ports(self, obj):
|
def setup_ports(self, obj):
|
||||||
self.file = tool.Ifc.get()
|
self.file = tool.Ifc.get()
|
||||||
self.collection = bpy.context.view_layer.active_layer_collection.collection
|
|
||||||
|
|
||||||
segment = tool.Ifc.get_entity(obj)
|
segment = tool.Ifc.get_entity(obj)
|
||||||
representation = ifcopenshell.util.representation.get_representation(segment, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(segment, "Model", "Body", "MODEL_VIEW")
|
||||||
|
|||||||
@@ -192,9 +192,9 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
|||||||
|
|
||||||
obj.location = context.scene.cursor.location
|
obj.location = context.scene.cursor.location
|
||||||
|
|
||||||
collection = context.view_layer.active_layer_collection.collection
|
self.container_obj = None
|
||||||
collection.objects.link(obj)
|
if container := tool.Root.get_default_container():
|
||||||
collection_obj = collection.BIMCollectionProperties.obj
|
self.container_obj = tool.Ifc.get_object(container)
|
||||||
|
|
||||||
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
|
||||||
tool.Blender.remove_data_block(mesh) # Remove "Instance" mesh
|
tool.Blender.remove_data_block(mesh) # Remove "Instance" mesh
|
||||||
@@ -248,11 +248,11 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
|||||||
# TODO For now we are hardcoding windows and doors as a prototype
|
# TODO For now we are hardcoding windows and doors as a prototype
|
||||||
bpy.ops.bim.add_filled_opening(voided_obj=building_obj.name, filling_obj=obj.name)
|
bpy.ops.bim.add_filled_opening(voided_obj=building_obj.name, filling_obj=obj.name)
|
||||||
else:
|
else:
|
||||||
if collection_obj and tool.Ifc.get_entity(collection_obj):
|
if self.container_obj:
|
||||||
if props.rl_mode == "BOTTOM":
|
if props.rl_mode == "BOTTOM":
|
||||||
obj.location.z = collection_obj.location.z - tool.Blender.get_object_bounding_box(obj)["min_z"]
|
obj.location.z = self.container_obj.location.z - tool.Blender.get_object_bounding_box(obj)["min_z"]
|
||||||
elif props.rl_mode == "CONTAINER":
|
elif props.rl_mode == "CONTAINER":
|
||||||
obj.location.z = collection_obj.location.z
|
obj.location.z = self.container_obj.location.z
|
||||||
elif props.rl_mode == "CURSOR":
|
elif props.rl_mode == "CURSOR":
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -274,11 +274,8 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def set_flow_segment_rl(self, obj):
|
def set_flow_segment_rl(self, obj):
|
||||||
collection = bpy.context.view_layer.active_layer_collection.collection
|
if self.container_obj:
|
||||||
collection_obj = collection.BIMCollectionProperties.obj
|
obj.location[2] = self.container_obj.location[2] + bpy.context.scene.BIMModelProperties.rl2
|
||||||
|
|
||||||
if collection_obj and tool.Ifc.get_entity(collection_obj):
|
|
||||||
obj.location[2] = collection_obj.location[2] + bpy.context.scene.BIMModelProperties.rl2
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_layered_element(ifc_class: str, relating_type: ifcopenshell.entity_instance) -> bool:
|
def generate_layered_element(ifc_class: str, relating_type: ifcopenshell.entity_instance) -> bool:
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import blenderbim.core.type
|
|||||||
import blenderbim.core.geometry
|
import blenderbim.core.geometry
|
||||||
import blenderbim.core.root
|
import blenderbim.core.root
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from math import radians
|
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
from blenderbim.bim.module.geometry.helper import Helper
|
from blenderbim.bim.module.geometry.helper import Helper
|
||||||
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
||||||
@@ -137,8 +136,10 @@ class DumbSlabGenerator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
props = bpy.context.scene.BIMModelProperties
|
props = bpy.context.scene.BIMModelProperties
|
||||||
self.collection = bpy.context.view_layer.active_layer_collection.collection
|
self.container = None
|
||||||
self.collection_obj = self.collection.BIMCollectionProperties.obj
|
if container := tool.Root.get_default_container():
|
||||||
|
self.container = container
|
||||||
|
self.container_obj = tool.Ifc.get_object(container)
|
||||||
self.depth = sum(thicknesses) * unit_scale
|
self.depth = sum(thicknesses) * unit_scale
|
||||||
self.width = 3
|
self.width = 3
|
||||||
self.length = 3
|
self.length = 3
|
||||||
@@ -161,13 +162,12 @@ class DumbSlabGenerator:
|
|||||||
|
|
||||||
matrix_world = Matrix()
|
matrix_world = Matrix()
|
||||||
matrix_world.translation = self.location
|
matrix_world.translation = self.location
|
||||||
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
if self.container_obj:
|
||||||
matrix_world.translation.z = self.collection_obj.location.z - self.depth
|
matrix_world.translation.z = self.container_obj.location.z - self.depth
|
||||||
else:
|
else:
|
||||||
matrix_world.translation.z -= self.depth
|
matrix_world.translation.z -= self.depth
|
||||||
obj.matrix_world = Matrix.Rotation(self.x_angle, 4, "X") @ matrix_world
|
obj.matrix_world = Matrix.Rotation(self.x_angle, 4, "X") @ matrix_world
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
self.collection.objects.link(obj)
|
|
||||||
|
|
||||||
element = blenderbim.core.root.assign_class(
|
element = blenderbim.core.root.assign_class(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import blenderbim.core.root
|
|||||||
import blenderbim.core.geometry
|
import blenderbim.core.geometry
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from math import pi, sin, cos, degrees, radians
|
from math import pi, sin, cos, degrees
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
from blenderbim.bim.module.model.opening import FilledOpeningGenerator
|
from blenderbim.bim.module.model.opening import FilledOpeningGenerator
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@@ -449,8 +449,10 @@ class DumbWallGenerator:
|
|||||||
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Axis", "GRAPH_VIEW")
|
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Axis", "GRAPH_VIEW")
|
||||||
|
|
||||||
props = bpy.context.scene.BIMModelProperties
|
props = bpy.context.scene.BIMModelProperties
|
||||||
self.collection = bpy.context.view_layer.active_layer_collection.collection
|
self.container = None
|
||||||
self.collection_obj = self.collection.BIMCollectionProperties.obj
|
if container := tool.Root.get_default_container():
|
||||||
|
self.container = container
|
||||||
|
self.container_obj = tool.Ifc.get_object(container)
|
||||||
self.width = self.layers["thickness"]
|
self.width = self.layers["thickness"]
|
||||||
self.height = props.extrusion_depth
|
self.height = props.extrusion_depth
|
||||||
self.length = props.length
|
self.length = props.length
|
||||||
@@ -540,11 +542,12 @@ class DumbWallGenerator:
|
|||||||
def derive_from_cursor(self):
|
def derive_from_cursor(self):
|
||||||
RAYCAST_PRECISION = 0.01
|
RAYCAST_PRECISION = 0.01
|
||||||
self.location = bpy.context.scene.cursor.location
|
self.location = bpy.context.scene.cursor.location
|
||||||
if self.collection:
|
if self.container:
|
||||||
for sibling_obj in self.collection.objects:
|
for subelement in ifcopenshell.util.element.get_decomposition(self.container):
|
||||||
if not isinstance(sibling_obj.data, bpy.types.Mesh):
|
if not subelement.is_a("IfcWall"):
|
||||||
continue
|
continue
|
||||||
if "IfcWall" not in sibling_obj.name:
|
sibling_obj = tool.Ifc.get_object(subelement)
|
||||||
|
if not sibling_obj or not isinstance(sibling_obj.data, bpy.types.Mesh):
|
||||||
continue
|
continue
|
||||||
inv_obj_matrix = sibling_obj.matrix_world.inverted()
|
inv_obj_matrix = sibling_obj.matrix_world.inverted()
|
||||||
local_location = inv_obj_matrix @ self.location
|
local_location = inv_obj_matrix @ self.location
|
||||||
@@ -594,11 +597,10 @@ class DumbWallGenerator:
|
|||||||
|
|
||||||
matrix_world = Matrix.Rotation(self.rotation, 4, "Z")
|
matrix_world = Matrix.Rotation(self.rotation, 4, "Z")
|
||||||
matrix_world.translation = self.location
|
matrix_world.translation = self.location
|
||||||
if self.collection_obj and self.collection_obj.BIMObjectProperties.ifc_definition_id:
|
if self.container_obj:
|
||||||
matrix_world.translation.z = self.collection_obj.location.z + props.rl1
|
matrix_world.translation.z = self.container_obj.location.z + props.rl1
|
||||||
obj.matrix_world = matrix_world
|
obj.matrix_world = matrix_world
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
self.collection.objects.link(obj)
|
|
||||||
|
|
||||||
element = blenderbim.core.root.assign_class(
|
element = blenderbim.core.root.assign_class(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
|
|||||||
Reference in New Issue
Block a user