mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +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,
|
||||
)
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.geometry
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -42,12 +43,20 @@ def get_subelement_class(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:
|
||||
entity = tool.Ifc.get().by_id(ifc_definition_id)
|
||||
obj = tool.Ifc.get_object(entity)
|
||||
if not obj:
|
||||
return
|
||||
obj.location.z = self.elevation
|
||||
if obj := tool.Ifc.get_object(entity):
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
obj.matrix_world[2][3] = elevation * unit_scale
|
||||
print('editing!')
|
||||
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj)
|
||||
|
||||
|
||||
def update_name(self, context):
|
||||
@@ -132,7 +141,7 @@ class BIMContainer(PropertyGroup):
|
||||
ifc_class: StringProperty(name="IFC Class")
|
||||
description: StringProperty(name="Description")
|
||||
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")
|
||||
has_children: BoolProperty(name="Has Children")
|
||||
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):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
self.draw_hierarchy(row, item)
|
||||
icon = {
|
||||
"IfcProject": "FILE",
|
||||
"IfcSite": "WORLD",
|
||||
@@ -243,12 +242,18 @@ class BIM_UL_containers_manager(UIList):
|
||||
"IfcRailwayPart": "MOD_FLUID",
|
||||
"IfcRoadPart": "MOD_FLUID",
|
||||
}.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:
|
||||
row.prop(item, "long_name", emboss=False, text="")
|
||||
col = row.column()
|
||||
col.alignment = "RIGHT"
|
||||
col.prop(item, "elevation", emboss=False, text="")
|
||||
split2 = split.split(factor=0.7)
|
||||
row = split2.row(align=True)
|
||||
self.draw_hierarchy(row, item)
|
||||
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):
|
||||
if item.level_index:
|
||||
|
||||
@@ -448,8 +448,7 @@ class Spatial(bonsai.core.tool.Spatial):
|
||||
new.long_name = element.LongName or ""
|
||||
if not element.is_a("IfcProject"):
|
||||
ifc_file = tool.Ifc.get()
|
||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
|
||||
new.elevation = ifcopenshell.util.placement.get_storey_elevation(element) * si_conversion
|
||||
new.elevation = str(ifcopenshell.util.placement.get_storey_elevation(element))
|
||||
new.is_expanded = element.id() not in cls.contracted_containers
|
||||
new.level_index = level_index
|
||||
children = ifcopenshell.util.element.get_parts(element)
|
||||
|
||||
Reference in New Issue
Block a user