mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
New feature to convert from local to global coordinates
This commit is contained in:
@@ -127,6 +127,7 @@ if bpy is not None:
|
|||||||
operator.RemoveVariable,
|
operator.RemoveVariable,
|
||||||
operator.PropagateTextData,
|
operator.PropagateTextData,
|
||||||
operator.PushRepresentation,
|
operator.PushRepresentation,
|
||||||
|
operator.ConvertLocalToGlobal,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.Variable,
|
prop.Variable,
|
||||||
prop.Classification,
|
prop.Classification,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from . import annotation
|
|||||||
from bpy_extras.io_utils import ImportHelper
|
from bpy_extras.io_utils import ImportHelper
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
from mathutils import Vector, Matrix, Euler
|
from mathutils import Vector, Matrix, Euler
|
||||||
from math import radians, atan, tan
|
from math import radians, atan, tan, cos, sin, atan2
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
colour_list = [
|
colour_list = [
|
||||||
@@ -2653,3 +2653,29 @@ class PushRepresentation(bpy.types.Operator):
|
|||||||
return element.ContextType == self.context \
|
return element.ContextType == self.context \
|
||||||
and element.ContextIdentifier == self.subcontext \
|
and element.ContextIdentifier == self.subcontext \
|
||||||
and element.TargetView == self.target_view
|
and element.TargetView == self.target_view
|
||||||
|
|
||||||
|
|
||||||
|
class ConvertLocalToGlobal(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.convert_local_to_global'
|
||||||
|
bl_label = 'Convert Local To Global'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
x, y, z = bpy.context.scene.cursor.location
|
||||||
|
|
||||||
|
if bpy.context.scene.MapConversion.scale:
|
||||||
|
scale = float(bpy.context.scene.MapConversion.scale)
|
||||||
|
else:
|
||||||
|
scale = 1.
|
||||||
|
|
||||||
|
rotation = atan2(
|
||||||
|
float(bpy.context.scene.MapConversion.x_axis_ordinate),
|
||||||
|
float(bpy.context.scene.MapConversion.x_axis_abscissa))
|
||||||
|
a = scale * cos(rotation)
|
||||||
|
b = scale * sin(rotation)
|
||||||
|
|
||||||
|
eastings = (a * x) - (b * y) + float(bpy.context.scene.MapConversion.eastings)
|
||||||
|
northings = (b * x) + (a * y) + float(bpy.context.scene.MapConversion.northings)
|
||||||
|
height = z + float(bpy.context.scene.MapConversion.orthogonal_height)
|
||||||
|
|
||||||
|
bpy.context.scene.cursor.location = (eastings, northings, height)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -535,6 +535,9 @@ class BIM_PT_gis(Panel):
|
|||||||
layout.row().prop(scene.TargetCRS, 'map_zone')
|
layout.row().prop(scene.TargetCRS, 'map_zone')
|
||||||
layout.row().prop(scene.TargetCRS, 'map_unit')
|
layout.row().prop(scene.TargetCRS, 'map_unit')
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.operator('bim.convert_local_to_global')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_documentation(Panel):
|
class BIM_PT_documentation(Panel):
|
||||||
bl_label = "Documentation"
|
bl_label = "Documentation"
|
||||||
|
|||||||
Reference in New Issue
Block a user