mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 21:38:12 +00:00
now spaces created with spatial tool have relative zero elevation origin point
This commit is contained in:
committed by
Massimo Fabbro
parent
2b926f7906
commit
c05d2df116
@@ -214,7 +214,7 @@ def generate_spaces_from_walls(ifc, spatial, collector):
|
|||||||
|
|
||||||
obj = spatial.get_named_obj_from_bmesh(name, bmesh=bm)
|
obj = spatial.get_named_obj_from_bmesh(name, bmesh=bm)
|
||||||
|
|
||||||
spatial.set_obj_origin_to_bboxcenter(obj)
|
spatial.set_obj_origin_to_bboxcenter_and_zero_elevation(obj)
|
||||||
spatial.traslate_obj_to_z_location(obj, z)
|
spatial.traslate_obj_to_z_location(obj, z)
|
||||||
|
|
||||||
spatial.link_obj_to_active_collection(obj)
|
spatial.link_obj_to_active_collection(obj)
|
||||||
|
|||||||
@@ -872,6 +872,7 @@ class Spatial:
|
|||||||
def get_transformed_mesh_from_local_to_global(cls, mesh): pass
|
def get_transformed_mesh_from_local_to_global(cls, mesh): pass
|
||||||
def edit_active_space_obj_from_mesh(cls, mesh): pass
|
def edit_active_space_obj_from_mesh(cls, mesh): pass
|
||||||
def set_obj_origin_to_bboxcenter(cls, obj): pass
|
def set_obj_origin_to_bboxcenter(cls, obj): pass
|
||||||
|
def set_obj_origin_to_bboxcenter_and_zero_elevation(cls, obj): pass
|
||||||
def set_obj_origin_to_cursor_position(cls, obj): pass
|
def set_obj_origin_to_cursor_position(cls, obj): pass
|
||||||
def get_selected_objects(cls): pass
|
def get_selected_objects(cls): pass
|
||||||
def get_active_obj(cls): pass
|
def get_active_obj(cls): pass
|
||||||
|
|||||||
@@ -582,6 +582,24 @@ class Spatial(blenderbim.core.tool.Spatial):
|
|||||||
vert.co = inverted @ aux_vector
|
vert.co = inverted @ aux_vector
|
||||||
obj.location = newLoc
|
obj.location = newLoc
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_obj_origin_to_bboxcenter_and_zero_elevation(cls, obj):
|
||||||
|
mat = obj.matrix_world
|
||||||
|
inverted = mat.inverted()
|
||||||
|
local_bbox_center = 0.125 * sum((Vector(b) for b in obj.bound_box), Vector())
|
||||||
|
global_bbox_center = mat @ local_bbox_center
|
||||||
|
global_obj_origin = global_bbox_center
|
||||||
|
global_obj_origin.z = 0
|
||||||
|
|
||||||
|
oldLoc = obj.location
|
||||||
|
newLoc = global_obj_origin
|
||||||
|
diff = newLoc - oldLoc
|
||||||
|
for vert in obj.data.vertices:
|
||||||
|
aux_vector = mat @ vert.co
|
||||||
|
aux_vector = aux_vector - diff
|
||||||
|
vert.co = inverted @ aux_vector
|
||||||
|
obj.location = newLoc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_obj_origin_to_cursor_position(cls, obj):
|
def set_obj_origin_to_cursor_position(cls, obj):
|
||||||
mat = obj.matrix_world
|
mat = obj.matrix_world
|
||||||
|
|||||||
Reference in New Issue
Block a user