mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix bunch of bugs related to grid name syncing, axis deleting, copy axes and grid deletion
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"axis": None}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
if len(self.file.get_inverse(self.settings["axis"].AxisCurve)) == 1:
|
||||
ifcopenshell.util.element.remove_deep(self.file, self.settings["axis"].AxisCurve)
|
||||
self.file.remove(self.settings["axis"].AxisCurve)
|
||||
self.file.remove(self.settings["axis"])
|
||||
@@ -11,6 +11,8 @@ class Usecase:
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
if not hasattr(self.settings["element"], "OwnerHistory"):
|
||||
return
|
||||
self.settings["person"] = ifcopenshell.api.owner.settings.get_person(self.file)
|
||||
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation(self.file)
|
||||
if not self.settings["element"].OwnerHistory:
|
||||
|
||||
@@ -18,11 +18,20 @@ class Usecase:
|
||||
elif self.settings["product"].is_a("IfcTypeProduct"):
|
||||
representations = [rm.MappedRepresentation for rm in self.settings["product"].RepresentationMaps or []]
|
||||
for representation in representations:
|
||||
ifcopenshell.api.run("geometry.unassign_representation",
|
||||
self.file, **{"product": self.settings["product"], "representation": representation}
|
||||
ifcopenshell.api.run(
|
||||
"geometry.unassign_representation",
|
||||
self.file,
|
||||
**{"product": self.settings["product"], "representation": representation}
|
||||
)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
|
||||
for opening in self.settings["product"].HasOpenings or []:
|
||||
for opening in getattr(self.settings["product"], "HasOpenings", []) or []:
|
||||
ifcopenshell.api.run("void.remove_opening", self.file, opening=opening.RelatedOpeningElement)
|
||||
|
||||
if self.settings["product"].is_a("IfcGrid"):
|
||||
for axis in (
|
||||
self.settings["product"].UAxes + self.settings["product"].VAxes + (self.settings["product"].WAxes or ())
|
||||
):
|
||||
ifcopenshell.api.run("grid.remove_grid_axis", self.file, axis=axis)
|
||||
|
||||
# TODO: remove object placement and other relationships
|
||||
self.file.remove(self.settings["product"])
|
||||
|
||||
Reference in New Issue
Block a user