Fix bunch of bugs related to grid name syncing, axis deleting, copy axes and grid deletion

This commit is contained in:
Dion Moult
2021-05-14 20:19:30 +10:00
parent 13c642c6ab
commit 41443d1a64
9 changed files with 55 additions and 8 deletions
+1 -1
View File
@@ -992,7 +992,7 @@ class GridDecorator(BaseDecorator):
p0 = location_3d_to_region_2d(region, region3d, v0)
p1 = location_3d_to_region_2d(region, region3d, v1)
dir = Vector((1, 0))
text = obj.BIMObjectProperties.attributes['AxisTag'].string_value
text = obj.name.split("/")[1].split(".")[0]
self.draw_label(context, text, p0, dir, vcenter=True, gap=0)
self.draw_label(context, text, p1, dir, vcenter=True, gap=0)
+10
View File
@@ -34,6 +34,16 @@ def name_callback(obj, data):
if element.is_a("IfcSpatialStructureElement") or (hasattr(element, "IsDecomposedBy") and element.IsDecomposedBy):
collection = obj.users_collection[0]
collection.name = obj.name
if element.is_a("IfcGrid"):
axis_obj = IfcStore.id_map[element.UAxes[0].id()]
axis_collection = axis_obj.users_collection[0]
grid_collection = None
for collection in bpy.data.collections:
if axis_collection.name in collection.children.keys():
grid_collection = collection
break
if grid_collection:
grid_collection.name = obj.name
if element.is_a("IfcTypeProduct"):
TypeData.purge()
element.Name = "/".join(obj.name.split("/")[1:])
@@ -24,7 +24,7 @@ class EnableEditingAttributes(bpy.types.Operator):
props.attributes.remove(0)
for attribute in Data.products[oprops.ifc_definition_id]:
new = props.attributes.add()
if attribute["type"] == "entity":
if attribute["type"] == "entity" or (attribute["type"] == "list" and attribute["list_type"] == "entity"):
continue
new.name = attribute["name"]
new.is_null = attribute["is_null"]
@@ -15,7 +15,7 @@ def draw_ui(context, layout, obj_type):
op = row.operator("bim.edit_attributes", icon="CHECKMARK", text="Save Attributes")
op.obj_type = obj_type
op.obj = obj.name
op = row.operator("bim.disable_editing_attributes", icon="X", text="")
op = row.operator("bim.disable_editing_attributes", icon="CANCEL", text="")
op.obj_type = obj_type
op.obj = obj.name
@@ -28,6 +28,7 @@ def add_object(self, context):
self.file = IfcStore.get_file()
if self.file:
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcGrid")
collection.name = obj.name
grid = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if has_site_collection:
site_obj = bpy.data.objects.get(grandchild.name)
@@ -58,6 +59,7 @@ def add_object(self, context):
self.file,
**{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "UAxes", "Grid": grid},
)
IfcStore.link_element(result, obj)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id()
@@ -77,12 +79,13 @@ def add_object(self, context):
axes_collection.objects.link(obj)
if IfcStore.get_file():
if self.file:
result = ifcopenshell.api.run(
"grid.create_grid_axis",
self.file,
**{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "VAxes", "Grid": grid},
)
IfcStore.link_element(result, obj)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id()
@@ -184,7 +184,15 @@ class UnassignClass(bpy.types.Operator):
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
self.remove_voids(product, obj)
IfcStore.unlink_element(product, obj)
ifcopenshell.api.run("root.remove_product", self.file, **{"product": product})
if product.is_a("IfcGridAxis"):
ifcopenshell.api.run("grid.remove_grid_axis", self.file, **{"axis": product})
elif product.is_a("IfcGrid"):
grid_collection = bpy.data.collections.get(obj.name)
for axis_collection in grid_collection.children:
for axis_obj in axis_collection.objects:
bpy.ops.bim.unassign_class(obj=axis_obj.name)
else:
ifcopenshell.api.run("root.remove_product", self.file, **{"product": product})
if "/" in obj.name and obj.name[0:3] == "Ifc":
obj.name = "/".join(obj.name.split("/")[1:])
if obj.data and obj.data.name == "Void":