mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Creating grids now uses tool.Collector.assign instead of reimplementing collection management
This commit is contained in:
@@ -28,23 +28,9 @@ def add_object(self, context):
|
|||||||
obj = bpy.data.objects.new("Grid", None)
|
obj = bpy.data.objects.new("Grid", None)
|
||||||
obj.name = "Grid"
|
obj.name = "Grid"
|
||||||
|
|
||||||
collection = context.view_layer.active_layer_collection.collection
|
|
||||||
site = tool.Ifc.get().by_type("IfcSite")
|
|
||||||
if site:
|
|
||||||
site = site[0]
|
|
||||||
site_obj = tool.Ifc.get_object(site)
|
|
||||||
if site_obj:
|
|
||||||
collection = site_obj.BIMObjectProperties.collection or collection
|
|
||||||
|
|
||||||
collection.objects.link(obj)
|
|
||||||
|
|
||||||
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcGrid")
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcGrid")
|
||||||
grid = tool.Ifc.get_entity(obj)
|
grid = tool.Ifc.get_entity(obj)
|
||||||
|
|
||||||
collection = obj.BIMObjectProperties.collection or collection
|
|
||||||
|
|
||||||
axes_collection = bpy.data.collections.new("UAxes")
|
|
||||||
collection.children.link(axes_collection)
|
|
||||||
for i in range(0, self.total_u):
|
for i in range(0, self.total_u):
|
||||||
verts = [
|
verts = [
|
||||||
Vector((-2, i * self.u_spacing, 0)),
|
Vector((-2, i * self.u_spacing, 0)),
|
||||||
@@ -57,19 +43,13 @@ def add_object(self, context):
|
|||||||
tag = chr(ord("A") + i)
|
tag = chr(ord("A") + i)
|
||||||
obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
|
obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
|
||||||
|
|
||||||
axes_collection.objects.link(obj)
|
|
||||||
|
|
||||||
result = ifcopenshell.api.run(
|
result = ifcopenshell.api.run(
|
||||||
"grid.create_grid_axis",
|
"grid.create_grid_axis", tool.Ifc.get(), axis_tag=tag, uvw_axes="UAxes", grid=grid
|
||||||
tool.Ifc.get(),
|
|
||||||
**{"axis_tag": tag, "uvw_axes": "UAxes", "grid": grid},
|
|
||||||
)
|
)
|
||||||
tool.Ifc.link(result, obj)
|
tool.Ifc.link(result, obj)
|
||||||
ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), **{"axis_curve": obj, "grid_axis": result})
|
ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), axis_curve=obj, grid_axis=result)
|
||||||
obj.BIMObjectProperties.ifc_definition_id = result.id()
|
tool.Collector.assign(obj)
|
||||||
|
|
||||||
axes_collection = bpy.data.collections.new("VAxes")
|
|
||||||
collection.children.link(axes_collection)
|
|
||||||
for i in range(0, self.total_v):
|
for i in range(0, self.total_v):
|
||||||
verts = [
|
verts = [
|
||||||
Vector((i * self.v_spacing, -2, 0)),
|
Vector((i * self.v_spacing, -2, 0)),
|
||||||
@@ -82,16 +62,12 @@ def add_object(self, context):
|
|||||||
tag = str(i + 1).zfill(2)
|
tag = str(i + 1).zfill(2)
|
||||||
obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
|
obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
|
||||||
|
|
||||||
axes_collection.objects.link(obj)
|
|
||||||
|
|
||||||
result = ifcopenshell.api.run(
|
result = ifcopenshell.api.run(
|
||||||
"grid.create_grid_axis",
|
"grid.create_grid_axis", tool.Ifc.get(), axis_tag=tag, uvw_axes="VAxes", grid=grid
|
||||||
tool.Ifc.get(),
|
|
||||||
**{"axis_tag": tag, "uvw_axes": "VAxes", "grid": grid},
|
|
||||||
)
|
)
|
||||||
tool.Ifc.link(result, obj)
|
tool.Ifc.link(result, obj)
|
||||||
ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), **{"axis_curve": obj, "grid_axis": result})
|
ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), axis_curve=obj, grid_axis=result)
|
||||||
obj.BIMObjectProperties.ifc_definition_id = result.id()
|
tool.Collector.assign(obj)
|
||||||
|
|
||||||
|
|
||||||
class BIM_OT_add_object(Operator, tool.Ifc.Operator):
|
class BIM_OT_add_object(Operator, tool.Ifc.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user