Skip to content

Commit dfd7357

Browse files
BBIM tree names, make it possible to adjust layout
1 parent 47704b1 commit dfd7357

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/blenderbim/blenderbim/bim/import_ifc.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ def create_grid_axes(self, axes, grid_collection, grid_obj):
800800
for axis in axes:
801801
shape = self.create_generic_shape(axis.AxisCurve)
802802
mesh = self.create_mesh(axis, shape)
803-
obj = bpy.data.objects.new(f"IfcGridAxis/{axis.AxisTag}", mesh)
803+
obj_name = tool.Loader.get_name_layout("IfcGridAxis", axis.AxisTag)
804+
obj = bpy.data.objects.new(obj_name, mesh)
804805
if bpy.context.preferences.addons["blenderbim"].preferences.lock_grids_on_import:
805806
obj.lock_location = (True, True, True)
806807
obj.lock_rotation = (True, True, True)
@@ -1059,11 +1060,11 @@ def create_structural_point_connections(self):
10591060
if not vertex or not context or not representation:
10601061
continue # TODO implement non cartesian point vertexes
10611062

1062-
mesh_name = f"{context.id()}/{representation.id()}"
1063+
mesh_name = tool.Loader.get_name_layout(context.id(), representation.id())
10631064
mesh = bpy.data.meshes.new(mesh_name)
10641065
mesh.from_pydata([mathutils.Vector(vertex) * self.unit_scale], [], [])
10651066

1066-
obj = bpy.data.objects.new("{}/{}".format(product.is_a(), product.Name), mesh)
1067+
obj = bpy.data.objects.new(tool.Loader.get_name(product), mesh)
10671068
self.set_matrix_world(obj, self.apply_blender_offset_to_matrix_world(obj, placement_matrix))
10681069
self.link_element(product, obj)
10691070

@@ -1124,12 +1125,12 @@ def create_pointcloud(
11241125
if len(vertex_list) == 0:
11251126
return None
11261127

1127-
mesh_name = f"{representation.ContextOfItems.id()}/{representation.id()}"
1128+
mesh_name = tool.Loader.get_name_layout(representation.ContextOfItems.id(), representation.id())
11281129
mesh = bpy.data.meshes.new(mesh_name)
11291130
mesh.from_pydata(vertex_list, [], [])
11301131
tool.Ifc.link(representation, mesh)
11311132

1132-
obj = bpy.data.objects.new("{}/{}".format(product.is_a(), product.Name), mesh)
1133+
obj = bpy.data.objects.new(tool.Loader.get_name(product), mesh)
11331134
self.set_matrix_world(obj, self.apply_blender_offset_to_matrix_world(obj, placement_matrix))
11341135
self.link_element(product, obj)
11351136
return product
@@ -1592,9 +1593,7 @@ def create_project(self):
15921593
self.project["blender"] = obj.BIMObjectProperties.collection
15931594
self.has_existing_project = True
15941595
return
1595-
self.project["blender"] = bpy.data.collections.new(
1596-
"{}/{}".format(self.project["ifc"].is_a(), self.project["ifc"].Name)
1597-
)
1596+
self.project["blender"] = bpy.data.collections.new(tool.Loader.get_name(self.project["ifc"]))
15981597
obj = self.create_product(self.project["ifc"])
15991598
obj.hide_select = True
16001599
self.project["blender"].objects.link(obj)

src/blenderbim/blenderbim/tool/loader.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,18 @@ def get_mesh_name(cls, geometry) -> str:
6363
representation_id = int(re.sub(r"\D", "", representation_id))
6464
representation = tool.Ifc.get().by_id(representation_id)
6565
context_id = representation.ContextOfItems.id() if hasattr(representation, "ContextOfItems") else 0
66-
return "{}/{}".format(context_id, representation_id)
66+
return cls.get_name_layout(context_id, representation_id)
6767

6868
@classmethod
6969
def get_name(cls, element: ifcopenshell.entity_instance) -> str:
70-
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
70+
return cls.get_name_layout(element.is_a(), getattr(element, "Name", "None"))
71+
72+
@classmethod
73+
def get_name_layout(cls, type, name) -> str:
74+
# TODO: use some user setting to change name layout
75+
return "{}/{}".format(type, name) # standard BBIM
76+
# return "{}: {}".format(type, name)
77+
# return "{}".format(name)
7178

7279
@classmethod
7380
def link_mesh(cls, shape, mesh: OBJECT_DATA_TYPE) -> None:

0 commit comments

Comments
 (0)