Fix bug in covering/space tool with matrix global and local

This commit is contained in:
Massimo Fabbro
2023-10-13 16:07:35 +02:00
committed by Massimo Fabbro
parent 25df2f6414
commit f1ab02b311
5 changed files with 14 additions and 6 deletions
@@ -131,7 +131,7 @@ class CoveringToolUI:
elif (element and
bpy.context.selected_objects and
element.is_a("IfcCovering") and
AuthoringData.data["predefined_type"] == "FLOORING" and
# AuthoringData.data["predefined_type"] == "FLOORING" and
AuthoringData.data["active_material_usage"] == "LAYER3"):
row = cls.layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
@@ -80,6 +80,7 @@ def regen_selected_flooring_object(ifc, spatial, model, Type, geometry):
name = "Aux"
mesh = spatial.get_named_mesh_from_bmesh(name = name, bmesh = bm)
mesh = spatial.get_transformed_mesh_from_local_to_global(mesh)
obj = spatial.get_named_obj_from_mesh(name, mesh)
points = spatial.get_2d_vertices_from_obj(obj)
@@ -157,6 +157,7 @@ def generate_space(ifc, spatial, model, Type):
mesh = spatial.get_named_mesh_from_bmesh(name = "Space", bmesh = bm)
if element and element.is_a("IfcSpace"):
mesh = spatial.get_transformed_mesh_from_local_to_global(mesh)
spatial.edit_active_space_obj_from_mesh(mesh)
else:
if relating_type:
+1
View File
@@ -828,6 +828,7 @@ class Spatial:
def get_named_obj_from_bmesh(cls, name, bmesh): pass
def get_named_obj_from_mesh(cls, name, mesh): pass
def get_named_mesh_from_bmesh(cls, name, bmesh): pass
def get_transformed_mesh_from_local_to_global(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_cursor_position(cls, obj): pass
+10 -5
View File
@@ -485,11 +485,7 @@ class Spatial(blenderbim.core.tool.Spatial):
@classmethod
def get_bmesh_from_polygon(cls, poly, h):
if bpy.context.selected_objects and bpy.context.active_object:
mat = bpy.context.active_object.matrix_world
else:
mat = Matrix()
mat = Matrix()
bm = bmesh.new()
bm.verts.index_update()
bm.edges.index_update()
@@ -534,6 +530,15 @@ class Spatial(blenderbim.core.tool.Spatial):
bmesh.free()
return mesh
@classmethod
def get_transformed_mesh_from_local_to_global(cls, mesh):
active_obj = cls.get_active_obj()
element = tool.Ifc.get_entity(active_obj)
mat = active_obj.matrix_world
mesh.transform(mat.inverted())
mesh.update()
return mesh
@classmethod
def edit_active_space_obj_from_mesh(cls, mesh):
active_obj = bpy.context.active_object