mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 22:47:53 +00:00
You can now easily get and set the cursor location for local<->global coordinate conversions
This commit is contained in:
@@ -11,6 +11,8 @@ classes = (
|
|||||||
operator.AddGeoreferencing,
|
operator.AddGeoreferencing,
|
||||||
operator.ConvertLocalToGlobal,
|
operator.ConvertLocalToGlobal,
|
||||||
operator.ConvertGlobalToLocal,
|
operator.ConvertGlobalToLocal,
|
||||||
|
operator.GetCursorLocation,
|
||||||
|
operator.SetCursorLocation,
|
||||||
prop.BIMGeoreferenceProperties,
|
prop.BIMGeoreferenceProperties,
|
||||||
ui.BIM_PT_gis,
|
ui.BIM_PT_gis,
|
||||||
ui.BIM_PT_gis_utilities,
|
ui.BIM_PT_gis_utilities,
|
||||||
|
|||||||
@@ -136,11 +136,9 @@ class EditGeoreferencing(bpy.types.Operator):
|
|||||||
if not props.is_map_unit_null:
|
if not props.is_map_unit_null:
|
||||||
map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial
|
map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial
|
||||||
|
|
||||||
edit_georeferencing.Usecase(self.file, {
|
edit_georeferencing.Usecase(
|
||||||
"map_conversion": map_conversion,
|
self.file, {"map_conversion": map_conversion, "projected_crs": projected_crs, "map_unit": map_unit}
|
||||||
"projected_crs": projected_crs,
|
).execute()
|
||||||
"map_unit": map_unit
|
|
||||||
}).execute()
|
|
||||||
Data.load()
|
Data.load()
|
||||||
bpy.ops.bim.disable_editing_georeferencing()
|
bpy.ops.bim.disable_editing_georeferencing()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -154,7 +152,7 @@ class SetNorthOffset(bpy.types.Operator):
|
|||||||
context.scene.sun_pos_properties.north_offset = -radians(
|
context.scene.sun_pos_properties.north_offset = -radians(
|
||||||
ifcopenshell.util.geolocation.xy2angle(
|
ifcopenshell.util.geolocation.xy2angle(
|
||||||
context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisAbscissa").float_value,
|
context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisAbscissa").float_value,
|
||||||
context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisOrdinate").float_value
|
context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisOrdinate").float_value,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -286,6 +284,28 @@ class ConvertGlobalToLocal(bpy.types.Operator):
|
|||||||
props.coordinate_output = ",".join([str(r) for r in results])
|
props.coordinate_output = ",".join([str(r) for r in results])
|
||||||
|
|
||||||
scale = ifcopenshell.util.unit.calculate_unit_scale(IfcStore.get_file())
|
scale = ifcopenshell.util.unit.calculate_unit_scale(IfcStore.get_file())
|
||||||
bpy.context.scene.cursor.location = (results[0] * scale, results[1] * scale, results[2] * scale)
|
bpy.context.scene.cursor.location = [o * scale for o in results]
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class GetCursorLocation(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.get_cursor_location"
|
||||||
|
bl_label = "Get Cursor Location"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
scale = ifcopenshell.util.unit.calculate_unit_scale(IfcStore.get_file())
|
||||||
|
project_coordinates = [o / scale for o in bpy.context.scene.cursor.location]
|
||||||
|
props.coordinate_input = ",".join([str(o) for o in project_coordinates])
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class SetCursorLocation(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.set_cursor_location"
|
||||||
|
bl_label = "Set Cursor Location"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
scale = ifcopenshell.util.unit.calculate_unit_scale(IfcStore.get_file())
|
||||||
|
bpy.context.scene.cursor.location = [float(co) * scale for co in props.coordinate_output.split(",")]
|
||||||
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -143,10 +143,12 @@ class BIM_PT_gis_utilities(Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
|
||||||
row = self.layout.row()
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "coordinate_input", text="Input")
|
row.prop(props, "coordinate_input", text="Input")
|
||||||
row = self.layout.row()
|
row.operator("bim.get_cursor_location", text="", icon="TRACKER")
|
||||||
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "coordinate_output", text="Output")
|
row.prop(props, "coordinate_output", text="Output")
|
||||||
|
row.operator("bim.set_cursor_location", text="", icon="TRACKER")
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.convert_local_to_global", text="Local to Global")
|
row.operator("bim.convert_local_to_global", text="Local to Global")
|
||||||
|
|||||||
Reference in New Issue
Block a user