mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Spatial manager renamed to project tree and added icons
This commit is contained in:
@@ -46,7 +46,7 @@ classes = (
|
||||
ui.BIM_PT_spatial,
|
||||
ui.BIM_UL_containers,
|
||||
ui.BIM_UL_containers_manager,
|
||||
ui.BIM_PT_SpatialManager,
|
||||
ui.BIM_PT_project_tree,
|
||||
workspace.Hotkey,
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import ifcopenshell.util.element
|
||||
|
||||
def refresh():
|
||||
SpatialData.is_loaded = False
|
||||
ProjectTreeData.is_loaded = False
|
||||
|
||||
|
||||
class SpatialData:
|
||||
@@ -34,13 +35,14 @@ class SpatialData:
|
||||
cls.is_loaded = True
|
||||
cls.data["poll"] = cls.poll()
|
||||
if cls.data["poll"]:
|
||||
cls.data.update({
|
||||
"parent_container_id": cls.parent_container_id(),
|
||||
"is_directly_contained": cls.is_directly_contained(),
|
||||
"label": cls.label(),
|
||||
"references": cls.references(),
|
||||
"containers": cls.containers(),
|
||||
})
|
||||
cls.data.update(
|
||||
{
|
||||
"parent_container_id": cls.parent_container_id(),
|
||||
"is_directly_contained": cls.is_directly_contained(),
|
||||
"label": cls.label(),
|
||||
"references": cls.references(),
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls):
|
||||
@@ -53,20 +55,6 @@ class SpatialData:
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def containers(cls):
|
||||
results = {}
|
||||
if tool.Ifc.get_schema() == "IFC2X3":
|
||||
spatial_elements = tool.Ifc.get().by_type("IfcSpatialStructureElement")
|
||||
else:
|
||||
spatial_elements = tool.Ifc.get().by_type("IfcSpatialElement")
|
||||
for container in spatial_elements:
|
||||
results[container.id()] = {
|
||||
"type": container.is_a(),
|
||||
"id": container.id(),
|
||||
}
|
||||
return results
|
||||
|
||||
@classmethod
|
||||
def parent_container_id(cls):
|
||||
container_id = bpy.context.scene.BIMSpatialProperties.active_container_id
|
||||
@@ -94,3 +82,29 @@ class SpatialData:
|
||||
@classmethod
|
||||
def is_directly_contained(cls):
|
||||
return bool(getattr(tool.Ifc.get_entity(bpy.context.active_object), "ContainedInStructure", False))
|
||||
|
||||
|
||||
class ProjectTreeData:
|
||||
data = {}
|
||||
is_loaded = False
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.is_loaded = True
|
||||
cls.data = {
|
||||
"containers": cls.containers(),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def containers(cls):
|
||||
results = {}
|
||||
if tool.Ifc.get_schema() == "IFC2X3":
|
||||
spatial_elements = tool.Ifc.get().by_type("IfcSpatialStructureElement")
|
||||
else:
|
||||
spatial_elements = tool.Ifc.get().by_type("IfcSpatialElement")
|
||||
for container in spatial_elements:
|
||||
results[container.id()] = {
|
||||
"type": container.is_a(),
|
||||
"id": container.id(),
|
||||
}
|
||||
return results
|
||||
|
||||
@@ -105,6 +105,9 @@ class BIMObjectSpatialProperties(PropertyGroup):
|
||||
|
||||
class BIMContainer(PropertyGroup):
|
||||
name: StringProperty(name="Name", update=updateContainerName)
|
||||
ifc_class: StringProperty(name="IFC Class")
|
||||
description: StringProperty(name="Description")
|
||||
long_name: StringProperty(name="Long Name")
|
||||
elevation: FloatProperty(name="Elevation", subtype="DISTANCE")
|
||||
level_index: IntProperty(name="Level Index")
|
||||
has_children: BoolProperty(name="Has Children")
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.module.spatial.data import SpatialData
|
||||
from blenderbim.bim.module.spatial.data import SpatialData, ProjectTreeData
|
||||
import blenderbim.tool as tool
|
||||
|
||||
|
||||
@@ -91,13 +91,12 @@ class BIM_UL_containers(UIList):
|
||||
)
|
||||
|
||||
|
||||
class BIM_PT_SpatialManager(Panel):
|
||||
bl_label = "Spatial Manager"
|
||||
bl_idname = "BIM_PT_SpatialManager"
|
||||
class BIM_PT_project_tree(Panel):
|
||||
bl_label = "Project Tree"
|
||||
bl_idname = "BIM_PT_project_tree"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_parent_id = "BIM_PT_tab_project_setup"
|
||||
|
||||
@classmethod
|
||||
@@ -105,8 +104,8 @@ class BIM_PT_SpatialManager(Panel):
|
||||
return tool.Ifc.get() and tool.Ifc.schema().name() != "IFC2X3"
|
||||
|
||||
def draw(self, context):
|
||||
if not SpatialData.is_loaded:
|
||||
SpatialData.load()
|
||||
if not ProjectTreeData.is_loaded:
|
||||
ProjectTreeData.load()
|
||||
self.props = context.scene.BIMSpatialManagerProperties
|
||||
row = self.layout.row()
|
||||
row.operator("bim.load_container_manager", icon="FILE_REFRESH", text="Load Spatial Structure")
|
||||
@@ -115,7 +114,7 @@ class BIM_PT_SpatialManager(Panel):
|
||||
row = self.layout.row()
|
||||
row.alignment = "RIGHT"
|
||||
row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="Select Children")
|
||||
spatial_data = SpatialData.data["containers"].get(ifc_definition_id, None)
|
||||
spatial_data = ProjectTreeData.data["containers"].get(ifc_definition_id, None)
|
||||
if spatial_data and spatial_data["type"] in ["IfcBuildingStorey", "IfcBuilding"]:
|
||||
row.operator("bim.add_building_storey", icon="ADD", text="Add storey").part_class = "IfcBuildingStorey"
|
||||
row.operator("bim.delete_container", icon="X", text="Delete").container = ifc_definition_id
|
||||
@@ -143,6 +142,7 @@ class BIM_UL_containers_manager(UIList):
|
||||
split1 = row.split(factor=0.7)
|
||||
split1.prop(item, "name", emboss=False, text="")
|
||||
split2 = row.split(factor=1)
|
||||
split2.alignment = "RIGHT"
|
||||
split2.label(icon="BLANK1", text=tool.Unit.blender_format_unit(item.elevation))
|
||||
|
||||
def draw_hierarchy(self, row, item):
|
||||
@@ -158,4 +158,14 @@ class BIM_UL_containers_manager(UIList):
|
||||
item.ifc_definition_id
|
||||
)
|
||||
else:
|
||||
row.label(text="", icon="DOT")
|
||||
row.label(text="", icon="BLANK1")
|
||||
if item.ifc_class == "IfcSite":
|
||||
row.label(text="", icon="WORLD")
|
||||
elif item.ifc_class == "IfcBuilding":
|
||||
row.label(text="", icon="HOME")
|
||||
elif item.ifc_class == "IfcBuildingStorey":
|
||||
row.label(text="", icon="LINENUMBERS_OFF")
|
||||
elif item.ifc_class == "IfcSpace":
|
||||
row.label(text="", icon="ANTIALIASED")
|
||||
else:
|
||||
row.label(text="", icon="META_PLANE")
|
||||
|
||||
@@ -64,16 +64,10 @@ def add_layout_hotkey(layout, text, hotkey, description):
|
||||
tool.Blender.add_layout_hotkey_operator(*args)
|
||||
|
||||
|
||||
# NOTES before adding new operators:
|
||||
# - add scene.BIMSpatialProperties
|
||||
# - add SpatialData
|
||||
|
||||
|
||||
class SpatialToolUI:
|
||||
@classmethod
|
||||
def draw(cls, context, layout):
|
||||
cls.layout = layout
|
||||
# cls.props = context.scene.BIMSpatialProperties
|
||||
cls.model_props = context.scene.BIMModelProperties
|
||||
|
||||
row = cls.layout.row(align=True)
|
||||
@@ -151,12 +145,10 @@ class Hotkey(bpy.types.Operator, Operator):
|
||||
return operator.description or ""
|
||||
|
||||
def _execute(self, context):
|
||||
# self.props = context.scene.BIMSpatialProperties
|
||||
getattr(self, f"hotkey_{self.hotkey}")()
|
||||
|
||||
def invoke(self, context, event):
|
||||
# https://blender.stackexchange.com/questions/276035/how-do-i-make-operators-remember-their-property-values-when-called-from-a-hotkey
|
||||
# self.props = context.scene.BIMSpatialProperties
|
||||
return self.execute(context)
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
Reference in New Issue
Block a user