If there is a Blender offset, show the non-offset placement in the placement panel

This commit is contained in:
Dion Moult
2023-11-22 11:32:14 +11:00
parent 94ce8e2c9c
commit 1f75fa09ae
2 changed files with 53 additions and 6 deletions
@@ -308,6 +308,9 @@ class PlacementData:
def load(cls):
cls.data = {
"has_placement": cls.has_placement(),
"original_x": cls.original_x(),
"original_y": cls.original_y(),
"original_z": cls.original_z(),
}
cls.is_loaded = True
@@ -317,3 +320,42 @@ class PlacementData:
if element and hasattr(element, "ObjectPlacement"):
return True
return False
@classmethod
def original_x(cls):
props = bpy.context.scene.BIMGeoreferenceProperties
obj = bpy.context.active_object
if not obj or not props.has_blender_offset:
return
return str(round(cls.original_xyz(obj.location)[0], 3))
@classmethod
def original_y(cls):
props = bpy.context.scene.BIMGeoreferenceProperties
obj = bpy.context.active_object
if not obj or not props.has_blender_offset:
return
return str(round(cls.original_xyz(obj.location)[1], 3))
@classmethod
def original_z(cls):
props = bpy.context.scene.BIMGeoreferenceProperties
obj = bpy.context.active_object
if not obj or not props.has_blender_offset:
return
return str(round(cls.original_xyz(obj.location)[2], 3))
@classmethod
def original_xyz(cls, location):
props = bpy.context.scene.BIMGeoreferenceProperties
return ifcopenshell.util.geolocation.xyz2enh(
location[0],
location[1],
location[2],
float(props.blender_eastings),
float(props.blender_northings),
float(props.blender_orthogonal_height),
float(props.blender_x_axis_abscissa),
float(props.blender_x_axis_ordinate),
1.0,
)
@@ -356,20 +356,25 @@ class BIM_PT_placement(Panel):
if not PlacementData.is_loaded:
PlacementData.load()
if PlacementData.data["has_placement"]:
row = self.layout.row()
row.prop(context.active_object, "location", text="Location")
row = self.layout.row()
row.prop(context.active_object, "rotation_euler", text="Rotation")
else:
if not PlacementData.data["has_placement"]:
row = self.layout.row()
row.label(text="No Object Placement Found")
return
row = self.layout.row()
row.prop(context.active_object, "location", text="Location")
row = self.layout.row()
row.prop(context.active_object, "rotation_euler", text="Rotation")
if context.active_object.BIMObjectProperties.blender_offset_type != "NONE":
row = self.layout.row(align=True)
row.label(text="Blender Offset", icon="TRACKING_REFINE_FORWARDS")
row.label(text=context.active_object.BIMObjectProperties.blender_offset_type)
row = self.layout.row(align=True)
row.label(text=PlacementData.data["original_x"], icon="EMPTY_AXIS")
row.label(text=PlacementData.data["original_y"])
row.label(text=PlacementData.data["original_z"])
class BIM_PT_derived_coordinates(Panel):
bl_label = "Derived Coordinates"