mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
New feature to add slab openings
This commit is contained in:
@@ -10,6 +10,7 @@ classes = (
|
|||||||
wall.FlipWall,
|
wall.FlipWall,
|
||||||
wall.SplitWall,
|
wall.SplitWall,
|
||||||
wall.AddWallOpening,
|
wall.AddWallOpening,
|
||||||
|
slab.AddSlabOpening,
|
||||||
prop.BIMModelProperties,
|
prop.BIMModelProperties,
|
||||||
ui.BIM_PT_authoring,
|
ui.BIM_PT_authoring,
|
||||||
ui.BIM_PT_authoring_architectural,
|
ui.BIM_PT_authoring_architectural,
|
||||||
|
|||||||
@@ -195,6 +195,44 @@ def calculate_quantities(usecase_path, ifc_file, settings):
|
|||||||
PsetData.load(ifc_file, obj.BIMObjectProperties.ifc_definition_id)
|
PsetData.load(ifc_file, obj.BIMObjectProperties.ifc_definition_id)
|
||||||
|
|
||||||
|
|
||||||
|
class AddSlabOpening(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_slab_opening"
|
||||||
|
bl_label = "Add Slab Opening"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
selected_objs = context.selected_objects
|
||||||
|
if len(selected_objs) == 0 or not context.active_object:
|
||||||
|
return {"FINISHED"}
|
||||||
|
slab_obj = context.active_object
|
||||||
|
if not slab_obj.BIMObjectProperties.ifc_definition_id:
|
||||||
|
return {"FINISHED"}
|
||||||
|
slab = IfcStore.get_file().by_id(slab_obj.BIMObjectProperties.ifc_definition_id)
|
||||||
|
if not slab.is_a("IfcSlab"):
|
||||||
|
return {"FINISHED"}
|
||||||
|
local_location = slab_obj.matrix_world.inverted() @ context.scene.cursor.location
|
||||||
|
raycast = slab_obj.closest_point_on_mesh(local_location, distance=0.01)
|
||||||
|
if not raycast[0]:
|
||||||
|
return {"FINISHED"}
|
||||||
|
bpy.ops.mesh.primitive_cube_add(size=slab_obj.dimensions[2] * 2)
|
||||||
|
opening = bpy.context.selected_objects[0]
|
||||||
|
|
||||||
|
# Place the opening in the middle of the slab
|
||||||
|
global_location = slab_obj.matrix_world @ raycast[1]
|
||||||
|
normal = raycast[2]
|
||||||
|
normal.negate()
|
||||||
|
global_normal = slab_obj.matrix_world.to_quaternion() @ normal
|
||||||
|
opening.location = global_location + (global_normal * (slab_obj.dimensions[2] / 2))
|
||||||
|
|
||||||
|
opening.rotation_euler = slab_obj.rotation_euler
|
||||||
|
opening.name = "Opening"
|
||||||
|
bpy.ops.bim.add_opening(opening=opening.name, obj=slab_obj.name)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DumbSlabGenerator:
|
class DumbSlabGenerator:
|
||||||
def __init__(self, relating_type):
|
def __init__(self, relating_type):
|
||||||
self.relating_type = relating_type
|
self.relating_type = relating_type
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ class AddWallOpening(bpy.types.Operator):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
return IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
selected_objs = context.selected_objects
|
selected_objs = context.selected_objects
|
||||||
if len(selected_objs) == 0 or not context.active_object:
|
if len(selected_objs) == 0 or not context.active_object:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -97,4 +97,4 @@ class Hotkey(bpy.types.Operator):
|
|||||||
if self.props.ifc_class == "IfcWallType":
|
if self.props.ifc_class == "IfcWallType":
|
||||||
bpy.ops.bim.add_wall_opening()
|
bpy.ops.bim.add_wall_opening()
|
||||||
elif self.props.ifc_class == "IfcSlabType":
|
elif self.props.ifc_class == "IfcSlabType":
|
||||||
pass
|
bpy.ops.bim.add_slab_opening()
|
||||||
|
|||||||
Reference in New Issue
Block a user