Minor fix

This commit is contained in:
Dion Moult
2022-08-22 17:02:05 +10:00
parent 9821c3af67
commit f50e790b11
9 changed files with 22 additions and 22 deletions
@@ -41,7 +41,7 @@ class LoadGroups(bpy.types.Operator):
context.scene.ExpandedGroups.json_string = "{}" context.scene.ExpandedGroups.json_string = "{}"
for ifc_definition_id, group in Data.groups.items(): for ifc_definition_id, group in Data.groups.items():
if not group["HasAssignments"]: if not group["HasAssignments"]:
new = self.props.groups.add() new = self.props.groups.add()
new.ifc_definition_id = ifc_definition_id new.ifc_definition_id = ifc_definition_id
new.name = group["Name"] new.name = group["Name"]
@@ -50,7 +50,7 @@ class LoadGroups(bpy.types.Operator):
if group["IsGroupedBy"]: if group["IsGroupedBy"]:
# assumes 1:1 cardinality, will need to be updated to reflect IFC4 changes # assumes 1:1 cardinality, will need to be updated to reflect IFC4 changes
# where the cardinality is 0:? - vulevukusej # where the cardinality is 0:? - vulevukusej
sub_groups = [g for g in group["IsGroupedBy"][0].RelatedObjects if g.is_a("IfcGroup")] sub_groups = [g for g in group["IsGroupedBy"][0].RelatedObjects if g.is_a("IfcGroup")]
new.has_children = True if len(sub_groups) != 0 else False new.has_children = True if len(sub_groups) != 0 else False
@@ -146,7 +146,7 @@ class AddGroupToGroup(bpy.types.Operator):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
result = ifcopenshell.api.run("group.add_group", self.file) result = ifcopenshell.api.run("group.add_group", self.file)
ifcopenshell.api.run( ifcopenshell.api.run(
"group.assign_group", IfcStore.get_file(), **{"product": [result], "group": self.file.by_id(self.group)} "group.assign_group", IfcStore.get_file(), products=[result], group=self.file.by_id(self.group)
) )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_groups(is_refresh=True) bpy.ops.bim.load_groups(is_refresh=True)
@@ -255,10 +255,8 @@ class AssignGroup(bpy.types.Operator):
ifcopenshell.api.run( ifcopenshell.api.run(
"group.assign_group", "group.assign_group",
self.file, self.file,
**{ products=[self.file.by_id(product.BIMObjectProperties.ifc_definition_id)],
"product": [self.file.by_id(product.BIMObjectProperties.ifc_definition_id)], group=self.file.by_id(self.group),
"group": self.file.by_id(self.group),
}
) )
Data.load(self.file) Data.load(self.file)
return {"FINISHED"} return {"FINISHED"}
@@ -332,7 +330,6 @@ class UpdateGroup(bpy.types.Operator):
**{ **{
"group": group, "group": group,
"products": new_products, "products": new_products,
} }
) )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
@@ -23,8 +23,10 @@ classes = (
operator.AssignContainer, operator.AssignContainer,
operator.ChangeSpatialLevel, operator.ChangeSpatialLevel,
operator.CopyToContainer, operator.CopyToContainer,
operator.DereferenceStructure,
operator.DisableEditingContainer, operator.DisableEditingContainer,
operator.EnableEditingContainer, operator.EnableEditingContainer,
operator.ReferenceStructure,
operator.RemoveContainer, operator.RemoveContainer,
operator.SelectContainer, operator.SelectContainer,
operator.SelectSimilarContainer, operator.SelectSimilarContainer,
@@ -663,7 +663,7 @@ class AddStructuralLoadGroup(bpy.types.Operator):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
load_group = ifcopenshell.api.run("structural.add_structural_load_group", self.file) load_group = ifcopenshell.api.run("structural.add_structural_load_group", self.file)
ifcopenshell.api.run( ifcopenshell.api.run(
"group.assign_group", self.file, product=[load_group], group=self.file.by_id(self.load_case) "group.assign_group", self.file, products=[load_group], group=self.file.by_id(self.load_case)
) )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -756,7 +756,7 @@ class AddStructuralActivity(bpy.types.Operator):
structural_member=element, structural_member=element,
) )
ifcopenshell.api.run( ifcopenshell.api.run(
"group.assign_group", self.file, product=[activity], group=self.file.by_id(self.load_group) "group.assign_group", self.file, products=[activity], group=self.file.by_id(self.load_group)
) )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.enable_editing_structural_load_group_activities(load_group=self.load_group) bpy.ops.bim.enable_editing_structural_load_group_activities(load_group=self.load_group)
+3 -3
View File
@@ -148,7 +148,7 @@ def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
) )
group = ifc.run("group.add_group") group = ifc.run("group.add_group")
ifc.run("group.edit_group", group=group, attributes={"Name": drawing_name, "ObjectType": "DRAWING"}) ifc.run("group.edit_group", group=group, attributes={"Name": drawing_name, "ObjectType": "DRAWING"})
ifc.run("group.assign_group", group=group, product=[element]) ifc.run("group.assign_group", group=group, products=[element])
collector.assign(camera) collector.assign(camera)
pset = ifc.run("pset.add_pset", product=element, name="EPset_Drawing") pset = ifc.run("pset.add_pset", product=element, name="EPset_Drawing")
ifc.run( ifc.run(
@@ -203,7 +203,7 @@ def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None)
context=context, context=context,
ifc_representation_class=drawing_tool.get_ifc_representation_class(object_type), ifc_representation_class=drawing_tool.get_ifc_representation_class(object_type),
) )
ifc.run("group.assign_group", group=drawing_tool.get_drawing_group(drawing), product=[element]) ifc.run("group.assign_group", group=drawing_tool.get_drawing_group(drawing), products=[element])
collector.assign(obj) collector.assign(obj)
drawing_tool.enable_editing(obj) drawing_tool.enable_editing(obj)
@@ -251,7 +251,7 @@ def sync_references(ifc, collector, drawing_tool, drawing=None):
annotation = drawing_tool.generate_reference_annotation(drawing, reference_element, context) annotation = drawing_tool.generate_reference_annotation(drawing, reference_element, context)
if annotation: if annotation:
ifc.run("drawing.assign_product", relating_product=reference_element, related_object=annotation) ifc.run("drawing.assign_product", relating_product=reference_element, related_object=annotation)
ifc.run("group.assign_group", group=group, product=[annotation]) ifc.run("group.assign_group", group=group, products=[annotation])
collector.assign(ifc.get_object(annotation)) collector.assign(ifc.get_object(annotation))
if reference_obj and ifc.is_moved(reference_obj): if reference_obj and ifc.is_moved(reference_obj):
+2 -2
View File
@@ -223,7 +223,7 @@ class TestAddDrawing:
ifc.run( ifc.run(
"group.edit_group", group="group", attributes={"Name": "name", "ObjectType": "DRAWING"} "group.edit_group", group="group", attributes={"Name": "name", "ObjectType": "DRAWING"}
).should_be_called() ).should_be_called()
ifc.run("group.assign_group", group="group", product=["element"]).should_be_called() ifc.run("group.assign_group", group="group", products=["element"]).should_be_called()
collector.assign("obj").should_be_called() collector.assign("obj").should_be_called()
ifc.run("pset.add_pset", product="element", name="EPset_Drawing").should_be_called().will_return("pset") ifc.run("pset.add_pset", product="element", name="EPset_Drawing").should_be_called().will_return("pset")
ifc.run( ifc.run(
@@ -293,7 +293,7 @@ class TestAddAnnotation:
ifc_representation_class="ifc_representation_class", ifc_representation_class="ifc_representation_class",
).should_be_called().will_return("element") ).should_be_called().will_return("element")
drawing.get_drawing_group("drawing").should_be_called().will_return("group") drawing.get_drawing_group("drawing").should_be_called().will_return("group")
ifc.run("group.assign_group", group="group", product=["element"]).should_be_called() ifc.run("group.assign_group", group="group", products=["element"]).should_be_called()
collector.assign("obj").should_be_called() collector.assign("obj").should_be_called()
drawing.enable_editing("obj").should_be_called() drawing.enable_editing("obj").should_be_called()
subject.add_annotation(ifc, collector, drawing, drawing="drawing", object_type="object_type") subject.add_annotation(ifc, collector, drawing, drawing="drawing", object_type="object_type")
+2 -2
View File
@@ -222,7 +222,7 @@ class TestAssign(NewFile):
tool.Ifc.link(element, element_obj) tool.Ifc.link(element, element_obj)
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get()) group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
group.ObjectType = "DRAWING" group.ObjectType = "DRAWING"
ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), product=[element], group=group) ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), products=[element], group=group)
subject.assign(element_obj) subject.assign(element_obj)
assert element_obj.users_collection[0].name == "IfcGroup/Unnamed" assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed") assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed")
@@ -235,7 +235,7 @@ class TestAssign(NewFile):
tool.Ifc.link(element, element_obj) tool.Ifc.link(element, element_obj)
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get()) group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
group.ObjectType = "DRAWING" group.ObjectType = "DRAWING"
ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), product=[element], group=group) ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), products=[element], group=group)
subject.assign(element_obj) subject.assign(element_obj)
assert element_obj.users_collection[0].name == "IfcGroup/Unnamed" assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed") assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed")
+2 -2
View File
@@ -260,7 +260,7 @@ class TestGetDrawingGroup(NewFile):
tool.Ifc.set(ifc) tool.Ifc.set(ifc)
element = ifc.createIfcAnnotation() element = ifc.createIfcAnnotation()
group = ifcopenshell.api.run("group.add_group", ifc) group = ifcopenshell.api.run("group.add_group", ifc)
ifcopenshell.api.run("group.assign_group", ifc, product=[element], group=group) ifcopenshell.api.run("group.assign_group", ifc, products=[element], group=group)
assert subject.get_drawing_group(element) == group assert subject.get_drawing_group(element) == group
@@ -280,7 +280,7 @@ class TestGetGroupElements(NewFile):
tool.Ifc.set(ifc) tool.Ifc.set(ifc)
element = ifc.createIfcAnnotation() element = ifc.createIfcAnnotation()
group = ifcopenshell.api.run("group.add_group", ifc) group = ifcopenshell.api.run("group.add_group", ifc)
ifcopenshell.api.run("group.assign_group", ifc, product=[element], group=group) ifcopenshell.api.run("group.assign_group", ifc, products=[element], group=group)
assert subject.get_group_elements(group) == (element,) assert subject.get_group_elements(group) == (element,)
@@ -24,7 +24,7 @@ class Usecase:
def __init__(self, file, **settings): def __init__(self, file, **settings):
self.file = file self.file = file
self.settings = { self.settings = {
"product": None, "products": None,
"group": None, "group": None,
} }
for key, value in settings.items(): for key, value in settings.items():
@@ -37,13 +37,13 @@ class Usecase:
**{ **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": self.settings["product"], "RelatedObjects": self.settings["products"],
"RelatingGroup": self.settings["group"], "RelatingGroup": self.settings["group"],
} }
) )
rel = self.settings["group"].IsGroupedBy[0] rel = self.settings["group"].IsGroupedBy[0]
related_objects = set(rel.RelatedObjects) or set() related_objects = set(rel.RelatedObjects) or set()
for obj in self.settings["product"]: for obj in self.settings["products"]:
related_objects.add(obj) related_objects.add(obj)
rel.RelatedObjects = list(related_objects) rel.RelatedObjects = list(related_objects)
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel}) ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
@@ -324,6 +324,7 @@ def get_referenced_structures(element):
""" """
if hasattr(element, "ReferencedInStructures"): if hasattr(element, "ReferencedInStructures"):
return [r.RelatingStructure for r in element.ReferencedInStructures] return [r.RelatingStructure for r in element.ReferencedInStructures]
return []
def get_decomposition(element): def get_decomposition(element):