Fix create space from cursor bug where spaces were created always in zero elevation

This commit is contained in:
Massimo Fabbro
2024-04-09 20:43:29 +02:00
committed by Massimo Fabbro
parent f021041b31
commit 74da327803
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -189,7 +189,8 @@ def generate_space(ifc, spatial, model, Type):
name = "Space"
obj = spatial.get_named_obj_from_mesh(name, mesh)
spatial.set_obj_origin_to_cursor_position(obj)
spatial.set_obj_origin_to_cursor_position_and_zero_elevation(obj)
spatial.traslate_obj_to_z_location(obj, z)
spatial.link_obj_to_active_collection(obj)
spatial.assign_ifcspace_class_to_obj(obj)
+1 -1
View File
@@ -873,7 +873,7 @@ class Spatial:
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_and_zero_elevation(cls, obj): pass
def set_obj_origin_to_cursor_position(cls, obj): pass
def set_obj_origin_to_cursor_position_and_zero_elevation(cls, obj): pass
def get_selected_objects(cls): pass
def get_active_obj(cls): pass
def get_active_obj_z(cls): pass
+2 -2
View File
@@ -601,14 +601,14 @@ class Spatial(blenderbim.core.tool.Spatial):
obj.location = newLoc
@classmethod
def set_obj_origin_to_cursor_position(cls, obj):
def set_obj_origin_to_cursor_position_and_zero_elevation(cls, obj):
mat = obj.matrix_world
inverted = mat.inverted()
collection = bpy.context.view_layer.active_layer_collection.collection
collection_obj = collection.BIMCollectionProperties.obj
x, y = bpy.context.scene.cursor.location.xy
z = collection_obj.matrix_world.translation.z
z = 0
oldLoc = obj.location
newLoc = Vector((x, y, z))