Use loader to get name instead of hardcoding when loading IFCs. See #4517.

This commit is contained in:
Dion Moult
2024-08-02 09:31:15 +10:00
parent 1abc3a1422
commit 788217c73c
2 changed files with 5 additions and 3 deletions
+3 -3
View File
@@ -551,7 +551,7 @@ class IfcImporter:
for axis in axes:
shape = tool.Loader.create_generic_shape(axis.AxisCurve)
mesh = self.create_mesh(axis, shape)
obj = bpy.data.objects.new(f"IfcGridAxis/{axis.AxisTag}", mesh)
obj = bpy.data.objects.new(tool.Loader.get_name(axis), mesh)
if tool.Blender.get_addon_preferences().lock_grids_on_import:
obj.lock_location = (True, True, True)
obj.lock_rotation = (True, True, True)
@@ -781,7 +781,7 @@ class IfcImporter:
mesh = bpy.data.meshes.new(mesh_name)
mesh.from_pydata([mathutils.Vector(vertex) * self.unit_scale], [], [])
obj = bpy.data.objects.new("{}/{}".format(product.is_a(), product.Name), mesh)
obj = bpy.data.objects.new(tool.Loader.get_name(product), mesh)
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, placement_matrix))
self.link_element(product, obj)
@@ -847,7 +847,7 @@ class IfcImporter:
mesh.from_pydata(vertex_list, [], [])
tool.Ifc.link(representation, mesh)
obj = bpy.data.objects.new("{}/{}".format(product.is_a(), product.Name), mesh)
obj = bpy.data.objects.new(tool.Loader.get_name(product), mesh)
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, placement_matrix))
self.link_element(product, obj)
return product
+2
View File
@@ -91,6 +91,8 @@ class Loader(blenderbim.core.tool.Loader):
@classmethod
def get_name(cls, element: ifcopenshell.entity_instance) -> str:
if element.is_a("IfcGridAxis"):
return "{}/{}".format(element.is_a(), element.AxisTag)
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
@classmethod