mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
Fix #5341. Editing elevations in spatial decomposition panel is now a string and has an immediate effect.
This commit is contained in:
@@ -31,6 +31,7 @@ from bpy.props import (
|
|||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
)
|
)
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
|
import bonsai.core.geometry
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
@@ -42,12 +43,20 @@ def get_subelement_class(self, context):
|
|||||||
|
|
||||||
|
|
||||||
def update_elevation(self, context):
|
def update_elevation(self, context):
|
||||||
|
try:
|
||||||
|
elevation = float(self.elevation)
|
||||||
|
if self.elevation != str(elevation):
|
||||||
|
self.elevation = str(elevation)
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
elevation = 0
|
||||||
if ifc_definition_id := self.ifc_definition_id:
|
if ifc_definition_id := self.ifc_definition_id:
|
||||||
entity = tool.Ifc.get().by_id(ifc_definition_id)
|
entity = tool.Ifc.get().by_id(ifc_definition_id)
|
||||||
obj = tool.Ifc.get_object(entity)
|
if obj := tool.Ifc.get_object(entity):
|
||||||
if not obj:
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
return
|
obj.matrix_world[2][3] = elevation * unit_scale
|
||||||
obj.location.z = self.elevation
|
print('editing!')
|
||||||
|
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj)
|
||||||
|
|
||||||
|
|
||||||
def update_name(self, context):
|
def update_name(self, context):
|
||||||
@@ -132,7 +141,7 @@ class BIMContainer(PropertyGroup):
|
|||||||
ifc_class: StringProperty(name="IFC Class")
|
ifc_class: StringProperty(name="IFC Class")
|
||||||
description: StringProperty(name="Description")
|
description: StringProperty(name="Description")
|
||||||
long_name: StringProperty(name="Long Name")
|
long_name: StringProperty(name="Long Name")
|
||||||
elevation: FloatProperty(name="Elevation", subtype="DISTANCE", update=update_elevation)
|
elevation: StringProperty(name="Elevation", update=update_elevation)
|
||||||
level_index: IntProperty(name="Level Index")
|
level_index: IntProperty(name="Level Index")
|
||||||
has_children: BoolProperty(name="Has Children")
|
has_children: BoolProperty(name="Has Children")
|
||||||
is_expanded: BoolProperty(name="Is Expanded")
|
is_expanded: BoolProperty(name="Is Expanded")
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ class BIM_UL_containers_manager(UIList):
|
|||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
self.draw_hierarchy(row, item)
|
|
||||||
icon = {
|
icon = {
|
||||||
"IfcProject": "FILE",
|
"IfcProject": "FILE",
|
||||||
"IfcSite": "WORLD",
|
"IfcSite": "WORLD",
|
||||||
@@ -243,12 +242,18 @@ class BIM_UL_containers_manager(UIList):
|
|||||||
"IfcRailwayPart": "MOD_FLUID",
|
"IfcRailwayPart": "MOD_FLUID",
|
||||||
"IfcRoadPart": "MOD_FLUID",
|
"IfcRoadPart": "MOD_FLUID",
|
||||||
}.get(item.ifc_class, "META_PLANE")
|
}.get(item.ifc_class, "META_PLANE")
|
||||||
row.prop(item, "name", emboss=False, text="", icon=icon)
|
split = row.split(factor=0.85)
|
||||||
if item.long_name:
|
if item.long_name:
|
||||||
row.prop(item, "long_name", emboss=False, text="")
|
split2 = split.split(factor=0.7)
|
||||||
col = row.column()
|
row = split2.row(align=True)
|
||||||
col.alignment = "RIGHT"
|
self.draw_hierarchy(row, item)
|
||||||
col.prop(item, "elevation", emboss=False, text="")
|
row.prop(item, "name", emboss=False, text="", icon=icon)
|
||||||
|
split2.prop(item, "long_name", emboss=False, text="")
|
||||||
|
else:
|
||||||
|
row = split.row(align=True)
|
||||||
|
self.draw_hierarchy(row, item)
|
||||||
|
row.prop(item, "name", emboss=False, text="", icon=icon)
|
||||||
|
split.prop(item, "elevation", emboss=False, text="")
|
||||||
|
|
||||||
def draw_hierarchy(self, row, item):
|
def draw_hierarchy(self, row, item):
|
||||||
if item.level_index:
|
if item.level_index:
|
||||||
|
|||||||
@@ -448,8 +448,7 @@ class Spatial(bonsai.core.tool.Spatial):
|
|||||||
new.long_name = element.LongName or ""
|
new.long_name = element.LongName or ""
|
||||||
if not element.is_a("IfcProject"):
|
if not element.is_a("IfcProject"):
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
|
new.elevation = str(ifcopenshell.util.placement.get_storey_elevation(element))
|
||||||
new.elevation = ifcopenshell.util.placement.get_storey_elevation(element) * si_conversion
|
|
||||||
new.is_expanded = element.id() not in cls.contracted_containers
|
new.is_expanded = element.id() not in cls.contracted_containers
|
||||||
new.level_index = level_index
|
new.level_index = level_index
|
||||||
children = ifcopenshell.util.element.get_parts(element)
|
children = ifcopenshell.util.element.get_parts(element)
|
||||||
|
|||||||
Reference in New Issue
Block a user