mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
New booleans UI panel to manage representation boolean stack
This commit is contained in:
@@ -281,6 +281,9 @@ class AddBoolean(Operator, tool.Ifc.Operator):
|
|||||||
is_global=True,
|
is_global=True,
|
||||||
should_sync_changes_first=False,
|
should_sync_changes_first=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tool.Ifc.unlink(obj=obj2)
|
||||||
|
bpy.data.objects.remove(obj2)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,7 +310,7 @@ class ShowBooleans(Operator, tool.Ifc.Operator, AddObjectHelper):
|
|||||||
boolean_obj = self.create_half_space_solid()
|
boolean_obj = self.create_half_space_solid()
|
||||||
position = boolean.BaseSurface.Position
|
position = boolean.BaseSurface.Position
|
||||||
position = Matrix(ifcopenshell.util.placement.get_axis2placement(position).tolist())
|
position = Matrix(ifcopenshell.util.placement.get_axis2placement(position).tolist())
|
||||||
boolean_obj.matrix_world = position
|
boolean_obj.matrix_world = obj.matrix_world @ position
|
||||||
boolean_obj.data.BIMMeshProperties.ifc_boolean_id = boolean.id()
|
boolean_obj.data.BIMMeshProperties.ifc_boolean_id = boolean.id()
|
||||||
boolean_obj.data.BIMMeshProperties.obj = obj
|
boolean_obj.data.BIMMeshProperties.obj = obj
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -146,8 +146,6 @@ class BimTool(WorkSpaceTool):
|
|||||||
op = row.operator("bim.change_layer_length", icon="FILE_REFRESH", text="")
|
op = row.operator("bim.change_layer_length", icon="FILE_REFRESH", text="")
|
||||||
op.length = props.length
|
op.length = props.length
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.label(text="Join")
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_E")
|
row.label(text="", icon="EVENT_E")
|
||||||
@@ -162,18 +160,9 @@ class BimTool(WorkSpaceTool):
|
|||||||
row.operator("bim.hotkey", text="Mitre").hotkey = "S_Y"
|
row.operator("bim.hotkey", text="Mitre").hotkey = "S_Y"
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_G")
|
|
||||||
row.operator("bim.hotkey", text="Regen Connections").hotkey = "S_G"
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
|
||||||
row.label(text="", icon="EVENT_M")
|
row.label(text="", icon="EVENT_M")
|
||||||
row.operator("bim.hotkey", text="Merge").hotkey = "S_M"
|
row.operator("bim.hotkey", text="Merge").hotkey = "S_M"
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.operator("bim.join_wall", icon="X", text="Disconnect").join_type = ""
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.label(text="Wall Tools")
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_F")
|
row.label(text="", icon="EVENT_F")
|
||||||
row.operator("bim.hotkey", text="Flip").hotkey = "S_F"
|
row.operator("bim.hotkey", text="Flip").hotkey = "S_F"
|
||||||
@@ -181,7 +170,11 @@ class BimTool(WorkSpaceTool):
|
|||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_S")
|
row.label(text="", icon="EVENT_S")
|
||||||
row.operator("bim.hotkey", text="Split").hotkey = "S_S"
|
row.operator("bim.hotkey", text="Split").hotkey = "S_S"
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
|
row.label(text="", icon="EVENT_G")
|
||||||
|
row.operator("bim.hotkey", text="Regen").hotkey = "S_G"
|
||||||
|
row.operator("bim.join_wall", icon="X", text="").join_type = ""
|
||||||
if ifc_class == "IfcSlabType":
|
if ifc_class == "IfcSlabType":
|
||||||
if not context.active_object:
|
if not context.active_object:
|
||||||
pass
|
pass
|
||||||
@@ -203,8 +196,6 @@ class BimTool(WorkSpaceTool):
|
|||||||
op = row.operator("bim.change_profile_depth", icon="FILE_REFRESH", text="")
|
op = row.operator("bim.change_profile_depth", icon="FILE_REFRESH", text="")
|
||||||
op.depth = props.extrusion_depth
|
op.depth = props.extrusion_depth
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.label(text="Join")
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_E")
|
row.label(text="", icon="EVENT_E")
|
||||||
@@ -224,9 +215,8 @@ class BimTool(WorkSpaceTool):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="", icon="EVENT_SHIFT")
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
row.label(text="", icon="EVENT_G")
|
row.label(text="", icon="EVENT_G")
|
||||||
row.operator("bim.hotkey", text="Regen Connections").hotkey = "S_G"
|
row.operator("bim.hotkey", text="Regen").hotkey = "S_G"
|
||||||
row = layout.row(align=True)
|
row.operator("bim.extend_profile", icon="X", text="").join_type = ""
|
||||||
row.operator("bim.extend_profile", icon="X", text="Disconnect").join_type = ""
|
|
||||||
|
|
||||||
if props.ifc_class in (
|
if props.ifc_class in (
|
||||||
"IfcCableCarrierSegmentType",
|
"IfcCableCarrierSegmentType",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ classes = (
|
|||||||
operator.ToggleDecompositionParenting,
|
operator.ToggleDecompositionParenting,
|
||||||
prop.VoidProperties,
|
prop.VoidProperties,
|
||||||
ui.BIM_PT_voids,
|
ui.BIM_PT_voids,
|
||||||
|
ui.BIM_PT_booleans,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
|
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||||
|
#
|
||||||
|
# This file is part of BlenderBIM Add-on.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
|
|
||||||
|
def refresh():
|
||||||
|
BooleansData.is_loaded = False
|
||||||
|
|
||||||
|
|
||||||
|
class BooleansData:
|
||||||
|
data = {}
|
||||||
|
is_loaded = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls):
|
||||||
|
cls.data = {"total_booleans": cls.total_booleans()}
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def total_booleans(cls):
|
||||||
|
obj = bpy.context.active_object
|
||||||
|
if (
|
||||||
|
not obj.data
|
||||||
|
or not hasattr(obj.data, "BIMMeshProperties")
|
||||||
|
or not obj.data.BIMMeshProperties.ifc_definition_id
|
||||||
|
):
|
||||||
|
return 0
|
||||||
|
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||||
|
total_booleans = 0
|
||||||
|
for item in representation.Items:
|
||||||
|
while True:
|
||||||
|
if item.is_a("IfcBooleanResult"):
|
||||||
|
total_booleans += 1
|
||||||
|
item = item.FirstOperand
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return total_booleans
|
||||||
@@ -20,6 +20,7 @@ import bpy
|
|||||||
from bpy.types import Panel
|
from bpy.types import Panel
|
||||||
from ifcopenshell.api.void.data import Data
|
from ifcopenshell.api.void.data import Data
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
from blenderbim.bim.module.void.data import BooleansData
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_voids(Panel):
|
class BIM_PT_voids(Panel):
|
||||||
@@ -115,3 +116,42 @@ class BIM_PT_voids(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=opening["Name"], icon="SELECT_INTERSECT")
|
row.label(text=opening["Name"], icon="SELECT_INTERSECT")
|
||||||
row.operator("bim.remove_filling", icon="X", text="")
|
row.operator("bim.remove_filling", icon="X", text="")
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_booleans(Panel):
|
||||||
|
bl_label = "IFC Booleans"
|
||||||
|
bl_idname = "BIM_PT_booleans"
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "data"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return (
|
||||||
|
context.active_object is not None
|
||||||
|
and context.active_object.type == "MESH"
|
||||||
|
and hasattr(context.active_object.data, "BIMMeshProperties")
|
||||||
|
and (
|
||||||
|
context.active_object.data.BIMMeshProperties.ifc_definition_id
|
||||||
|
or context.active_object.data.BIMMeshProperties.ifc_boolean_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
if not BooleansData.is_loaded:
|
||||||
|
BooleansData.load()
|
||||||
|
|
||||||
|
if not context.active_object.data:
|
||||||
|
return
|
||||||
|
layout = self.layout
|
||||||
|
props = context.active_object.data.BIMMeshProperties
|
||||||
|
|
||||||
|
if context.active_object.data.BIMMeshProperties.ifc_definition_id:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text=f"{BooleansData.data['total_booleans']} Booleans Found")
|
||||||
|
row.operator("bim.add_boolean", text="", icon="ADD")
|
||||||
|
row.operator("bim.show_booleans", text="", icon="HIDE_OFF")
|
||||||
|
row.operator("bim.hide_booleans", text="", icon="HIDE_ON")
|
||||||
|
elif context.active_object.data.BIMMeshProperties.ifc_boolean_id:
|
||||||
|
row = layout.row()
|
||||||
|
row.operator("bim.remove_booleans", text="Remove Boolean", icon="X")
|
||||||
|
|||||||
Reference in New Issue
Block a user