ifcopenshell.api.run to use explicit kwargs instead of unpacking

This commit is contained in:
Andrej
2025-06-10 11:02:54 +05:00
parent a37d46ca3d
commit 1608677d40
52 changed files with 118 additions and 147 deletions
@@ -848,10 +848,8 @@ class ReorderCostItem(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
ifcopenshell.api.nest.reorder_nesting(
tool.Ifc.get(),
**{
"item": tool.Ifc.get().by_id(self.cost_item),
"new_index": self.new_index,
},
item=tool.Ifc.get().by_id(self.cost_item),
new_index=self.new_index,
)
tool.Cost.load_cost_schedule_tree()
@@ -140,7 +140,7 @@ class RemoveGroup(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
self.file = tool.Ifc.get()
ifcopenshell.api.group.remove_group(self.file, **{"group": self.file.by_id(self.group)})
ifcopenshell.api.group.remove_group(self.file, group=self.file.by_id(self.group))
bpy.ops.bim.load_groups()
return {"FINISHED"}
@@ -122,11 +122,12 @@ class AssignParameterizedProfile(bpy.types.Operator, tool.Ifc.Operator):
self.file = tool.Ifc.get()
profile = ifcopenshell.api.profile.add_parameterized_profile(
self.file,
**{"ifc_class": self.ifc_class},
ifc_class=self.ifc_class,
)
ifcopenshell.api.material.assign_profile(
self.file,
**{"material_profile": self.file.by_id(self.material_profile), "profile": profile},
material_profile=self.file.by_id(self.material_profile),
profile=profile,
)
bpy.ops.bim.enable_editing_material_set_item(obj=obj.name, material_set_item=self.material_profile)
@@ -471,10 +472,8 @@ class RemoveListItem(bpy.types.Operator, tool.Ifc.Operator):
self.file = tool.Ifc.get()
ifcopenshell.api.material.remove_list_item(
self.file,
**{
"material_list": self.file.by_id(self.list_item_set),
"material_index": self.list_item_index,
},
material_list=self.file.by_id(self.list_item_set),
material_index=self.list_item_index,
)
@@ -691,7 +691,8 @@ def generate_box(usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[
ifcopenshell.api.geometry.assign_representation(
ifc_file,
should_run_listeners=False,
**{"product": product, "representation": new_box},
product=product,
representation=new_box,
)
+2 -1
View File
@@ -924,7 +924,8 @@ class DrawPolylineSlab(bpy.types.Operator, PolylineOperator, tool.Ifc.Operator):
attributes = {"OffsetFromReferenceLine": offset, "DirectionSense": direction_sense}
ifcopenshell.api.material.edit_layer_usage(
model,
**{"usage": material_set_usage, "attributes": attributes},
usage=material_set_usage,
attributes=attributes,
)
DumbSlabPlaner().regenerate_from_occurence(element, material_set_usage)
@@ -84,7 +84,7 @@ class RemovePsetTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOpera
bpy.ops.bim.disable_editing_pset_template()
ifcopenshell.api.pset_template.remove_pset_template(
self.template_file,
**{"pset_template": self.template_file.by_id(current_pset_template_id)},
pset_template=self.template_file.by_id(current_pset_template_id),
)
self.template_file.write(IfcStore.pset_template_path)
bonsai.bim.handler.refresh_ui_data()
@@ -170,14 +170,12 @@ class EditPsetTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperato
props = tool.PsetTemplate.get_pset_template_props()
ifcopenshell.api.pset_template.edit_pset_template(
IfcStore.pset_template_file,
**{
"pset_template": IfcStore.pset_template_file.by_id(props.active_pset_template_id),
"attributes": {
"Name": props.active_pset_template.name,
"Description": props.active_pset_template.description,
"TemplateType": props.active_pset_template.template_type,
"ApplicableEntity": props.active_pset_template.applicable_entity,
},
pset_template=IfcStore.pset_template_file.by_id(props.active_pset_template_id),
attributes={
"Name": props.active_pset_template.name,
"Description": props.active_pset_template.description,
"TemplateType": props.active_pset_template.template_type,
"ApplicableEntity": props.active_pset_template.applicable_entity,
},
)
bpy.ops.bim.disable_editing_pset_template()
@@ -250,7 +248,7 @@ class RemovePropTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOpera
def _execute(self, context):
ifcopenshell.api.pset_template.remove_prop_template(
IfcStore.pset_template_file,
**{"prop_template": IfcStore.pset_template_file.by_id(self.prop_template)},
prop_template=IfcStore.pset_template_file.by_id(self.prop_template),
)
IfcStore.pset_template_file.write(IfcStore.pset_template_path)
bonsai.bim.handler.refresh_ui_data()
@@ -137,7 +137,7 @@ class RemoveStructuralConnectionCondition(bpy.types.Operator, tool.Ifc.Operator)
file = tool.Ifc.get()
relation = file.by_id(self.connects_structural_member)
connection = relation.RelatedStructuralConnection
ifcopenshell.api.structural.remove_structural_connection_condition(file, **{"relation": relation})
ifcopenshell.api.structural.remove_structural_connection_condition(file, relation=relation)
return {"FINISHED"}
@@ -150,7 +150,7 @@ class AddStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
file = tool.Ifc.get()
connection = file.by_id(self.connection)
ifcopenshell.api.structural.add_structural_boundary_condition(file, **{"connection": connection})
ifcopenshell.api.structural.add_structural_boundary_condition(file, connection=connection)
return {"FINISHED"}
@@ -163,7 +163,7 @@ class RemoveStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
file = tool.Ifc.get()
connection = file.by_id(self.connection)
ifcopenshell.api.structural.remove_structural_boundary_condition(file, **{"connection": connection})
ifcopenshell.api.structural.remove_structural_boundary_condition(file, connection=connection)
return {"FINISHED"}
@@ -234,9 +234,7 @@ class EditStructuralBoundaryCondition(bpy.types.Operator, tool.Ifc.Operator):
else:
attributes[attribute.name] = {"value": attribute.float_value, "type": attribute.enum_value}
ifcopenshell.api.structural.edit_structural_boundary_condition(
file, **{"condition": condition, "attributes": attributes}
)
ifcopenshell.api.structural.edit_structural_boundary_condition(file, condition=condition, attributes=attributes)
bpy.ops.bim.disable_editing_structural_boundary_condition()
return {"FINISHED"}
@@ -538,10 +536,8 @@ class AssignStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
self.file = tool.Ifc.get()
ifcopenshell.api.aggregate.assign_object(
self.file,
**{
"relating_object": self.file.by_id(self.work_plan),
"products": [self.file.by_id(self.load_case)],
},
relating_object=self.file.by_id(self.work_plan),
products=[self.file.by_id(self.load_case)],
)
return {"FINISHED"}
+7 -13
View File
@@ -39,10 +39,8 @@ def assign_structural_analysis_model(
) -> None:
ifc.run(
"structural.assign_structural_analysis_model",
**{
"products": products,
"structural_analysis_model": structural_analysis_model,
},
products=products,
structural_analysis_model=structural_analysis_model,
)
@@ -58,10 +56,8 @@ def edit_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural) -
attributes = structural.get_structural_analysis_model_attributes()
ifc.run(
"structural.edit_structural_analysis_model",
**{
"structural_analysis_model": structural.get_active_structural_analysis_model(),
"attributes": attributes,
},
structural_analysis_model=structural.get_active_structural_analysis_model(),
attributes=attributes,
)
structural.load_structural_analysis_models()
structural.disable_editing_structural_analysis_model()
@@ -91,7 +87,7 @@ def load_structural_analysis_models(structural: tool.Structural) -> None:
def remove_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural, model: int) -> None:
ifc.run(
"structural.remove_structural_analysis_model",
**{"structural_analysis_model": ifc.get().by_id(model)},
structural_analysis_model=ifc.get().by_id(model),
)
structural.load_structural_analysis_models()
@@ -103,8 +99,6 @@ def unassign_structural_analysis_model(
) -> None:
ifc.run(
"structural.unassign_structural_analysis_model",
**{
"products": products,
"structural_analysis_model": structural_analysis_model,
},
products=products,
structural_analysis_model=structural_analysis_model,
)
+8 -11
View File
@@ -282,10 +282,8 @@ class ScheduleIfcGenerator:
# Seems intermittently crashy - can we investigate for larger files?
ifcopenshell.api.control.assign_control(
self.file,
**{
"relating_control": calendar["ifc"],
"related_object": activity["ifc"],
},
relating_control=calendar["ifc"],
related_object=activity["ifc"],
)
ifcopenshell.api.sequence.edit_task_time(
self.file,
@@ -339,20 +337,19 @@ class ScheduleIfcGenerator:
if not parent.get("ifc"):
parent["ifc"] = ifcopenshell.api.resource.add_resource(
self.file,
**{"ifc_class": "IfcCrewResource", "name": parent["Name"]},
ifc_class="IfcCrewResource",
name=parent["Name"],
)
if parent:
resource["ifc"] = ifcopenshell.api.resource.add_resource(
self.file,
**{
"parent_resource": parent["ifc"] if parent else None,
"ifc_class": "IfcCrewResource",
"name": resource["Name"],
},
parent_resource=parent["ifc"] if parent else None,
ifc_class="IfcCrewResource",
name=resource["Name"],
)
else:
resource["ifc"] = ifcopenshell.api.resource.add_resource(
self.file, **{"ifc_class": "IfcCrewResource", "name": resource["Name"]}
self.file, ifc_class="IfcCrewResource", name=resource["Name"]
)
def create_boilerplate_ifc(self) -> None:
+2 -4
View File
@@ -262,10 +262,8 @@ class MSP2Ifc:
if calendar:
ifcopenshell.api.control.assign_control(
self.file,
**{
"relating_control": calendar,
"related_object": task["ifc"],
},
relating_control=calendar,
related_object=task["ifc"],
)
ifcopenshell.api.sequence.edit_task(
@@ -174,13 +174,12 @@ class Cityjson2ifc:
self.IFC_model = ifcopenshell.api.project.create_file()
self.IFC_project = ifcopenshell.api.root.create_entity(
self.IFC_model,
**{"ifc_class": "IfcProject", "name": self.properties.get("name_project", "My Project")},
ifc_class="IfcProject",
name=self.properties.get("name_project", "My Project"),
)
ifcopenshell.api.unit.assign_unit(self.IFC_model, length={"is_metric": True, "raw": "METERS"})
self.properties["owner_history"] = self.create_owner_history()
self.IFC_representation_context = ifcopenshell.api.context.add_context(
self.IFC_model, **{"context_type": "Model"}
)
self.IFC_representation_context = ifcopenshell.api.context.add_context(self.IFC_model, context_type="Model")
if not self.city_model.has_metadata() or "presentLoDs" not in self.city_model.j["metadata"]:
self.city_model.update_metadata()
@@ -123,7 +123,7 @@ def assign_object(
related_objects = set(decomposes.RelatedObjects) - products_set
if related_objects:
decomposes.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": decomposes})
ifcopenshell.api.owner.update_owner_history(file, element=decomposes)
else:
history = decomposes.OwnerHistory
file.remove(decomposes)
@@ -133,7 +133,7 @@ def assign_object(
# assign elements to a new aggregate
if is_decomposed_by:
is_decomposed_by.RelatedObjects = list(set(is_decomposed_by.RelatedObjects) | products_set)
ifcopenshell.api.owner.update_owner_history(file, **{"element": is_decomposed_by})
ifcopenshell.api.owner.update_owner_history(file, element=is_decomposed_by)
else:
is_decomposed_by = file.create_entity(
"IfcRelAggregates",
@@ -69,7 +69,7 @@ def unassign_object(file: ifcopenshell.file, products: list[ifcopenshell.entity_
related_objects = set(rel.RelatedObjects) - products
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -86,4 +86,4 @@ def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instan
product.PredefinedType = "USERDEFINED"
if hasattr(product, "OwnerHistory"):
ifcopenshell.api.owner.update_owner_history(file, **{"element": product})
ifcopenshell.api.owner.update_owner_history(file, element=product)
@@ -231,7 +231,7 @@ class Usecase:
if root_rel:
related_objects = set(root_rel.RelatedObjects) | self.rooted_products
root_rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": root_rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=root_rel)
else:
self.file.create_entity(
"IfcRelAssociatesClassification",
@@ -88,7 +88,7 @@ def remove_reference(
related_objects = set(rel.RelatedObjects) - rooted_products
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -70,7 +70,7 @@ class Usecase:
if rel:
related_objects = set(rel.RelatedObjects) | products_to_assign
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
return rel
return self.file.create_entity(
@@ -63,7 +63,7 @@ class Usecase:
related_objects -= products_set
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
continue
history = rel.OwnerHistory
@@ -84,7 +84,7 @@ def assign_control(
related_objects = set(controls.RelatedObjects)
related_objects.add(related_object)
controls.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": controls})
ifcopenshell.api.owner.update_owner_history(file, element=controls)
else:
controls = file.create_entity(
"IfcRelAssignsToControl",
@@ -63,5 +63,5 @@ def unassign_control(
related_objects = list(rel.RelatedObjects)
related_objects.remove(related_object)
rel.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
return rel
@@ -68,7 +68,7 @@ def unassign_document(
related_objects = set(rel.RelatedObjects) - products_set
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -75,7 +75,7 @@ class Usecase:
self.file, representation=self.settings["representation"]
)
self.assign_product_representation(element, mapped_representation)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
ifcopenshell.api.owner.update_owner_history(self.file, element=self.settings["product"])
def assign_product_representation(
self, product: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance
@@ -101,7 +101,7 @@ class Usecase:
new_placement.PlacementRelTo = placement_rel_to
self.settings["product"].ObjectPlacement = new_placement
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
ifcopenshell.api.owner.update_owner_history(self.file, element=self.settings["product"])
for settings in children_settings:
self.settings = settings
@@ -63,5 +63,5 @@ def assign_group(
if products_set.issubset(related_objects):
return rel
rel.RelatedObjects = list(related_objects | products_set)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
return rel
@@ -54,7 +54,7 @@ def unassign_group(
related_objects -= products_set
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -70,7 +70,7 @@ def unassign_reference(
related_objects = set(rel.RelatedObjects) - products_set
if related_objects:
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -328,7 +328,7 @@ class Usecase:
return self.create_material_association(material)
previous_related_objects = set(rel.RelatedObjects)
rel.RelatedObjects = list(previous_related_objects | self.products)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
return rel
def create_material_association(
@@ -132,4 +132,4 @@ class Usecase:
ifcopenshell.util.element.remove_deep2(self.file, history)
continue
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
@@ -146,7 +146,7 @@ def assign_object(
cur_related_objects = [o for o in nests.RelatedObjects if o not in related_objects_set]
if cur_related_objects:
nests.RelatedObjects = list(cur_related_objects)
ifcopenshell.api.owner.update_owner_history(file, **{"element": nests})
ifcopenshell.api.owner.update_owner_history(file, element=nests)
else:
history = nests.OwnerHistory
file.remove(nests)
@@ -160,7 +160,7 @@ def assign_object(
is_nested_by.RelatedObjects = cur_related_objects + [
o for o in related_objects if o not in cur_related_objects_set
]
ifcopenshell.api.owner.update_owner_history(file, **{"element": is_nested_by})
ifcopenshell.api.owner.update_owner_history(file, element=is_nested_by)
else:
is_nested_by = file.create_entity(
"IfcRelNests",
@@ -33,7 +33,7 @@ def change_nest(
related_objects.remove(item)
if related_objects:
nests.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": nests})
ifcopenshell.api.owner.update_owner_history(file, element=nests)
else:
history = nests.OwnerHistory
file.remove(nests)
@@ -66,7 +66,7 @@ def unassign_object(file: ifcopenshell.file, related_objects: list[ifcopenshell.
cur_related_objects = [o for o in rel.RelatedObjects if o not in related_objects_set]
if cur_related_objects:
rel.RelatedObjects = cur_related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -85,7 +85,7 @@ def assign_actor(
related_objects = list(rel.RelatedObjects)
related_objects.append(related_object)
rel.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
rel = file.create_entity(
"IfcRelAssignsToActor",
@@ -64,4 +64,4 @@ def unassign_actor(
related_objects = list(rel.RelatedObjects)
related_objects.remove(related_object)
rel.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
@@ -123,7 +123,7 @@ def assign_declaration(
related_definitions = set(has_context.RelatedDefinitions) - set(objects_with_contexts)
if related_definitions:
has_context.RelatedDefinitions = list(related_definitions)
ifcopenshell.api.owner.update_owner_history(file, **{"element": has_context})
ifcopenshell.api.owner.update_owner_history(file, element=has_context)
else:
history = has_context.OwnerHistory
file.remove(has_context)
@@ -133,7 +133,7 @@ def assign_declaration(
declares = next(iter(all_declares), None)
if declares:
declares.RelatedDefinitions = list(set(declares.RelatedDefinitions) | set(objects_to_change))
ifcopenshell.api.owner.update_owner_history(file, **{"element": declares})
ifcopenshell.api.owner.update_owner_history(file, element=declares)
else:
declares = file.create_entity(
"IfcRelDeclares",
@@ -67,7 +67,7 @@ def unassign_declaration(
related_definitions = set(rel.RelatedDefinitions) - definitions
if related_definitions:
rel.RelatedDefinitions = list(related_definitions)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -92,7 +92,7 @@ def assign_resource(
related_objects = list(resource_of.RelatedObjects)
related_objects.append(related_object)
resource_of.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": resource_of})
ifcopenshell.api.owner.update_owner_history(file, element=resource_of)
else:
resource_of = file.create_entity(
"IfcRelAssignsToResource",
@@ -69,4 +69,4 @@ def unassign_resource(
related_objects = list(rel.RelatedObjects)
related_objects.remove(related_object)
rel.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
@@ -100,10 +100,8 @@ def add_work_schedule(
if work_plan:
ifcopenshell.api.aggregate.assign_object(
file,
**{
"products": [work_schedule],
"relating_object": work_plan,
}
products=[work_schedule],
relating_object=work_plan,
)
elif file.schema != "IFC2X3":
# TODO: this is an ambiguity by buildingSMART
@@ -101,7 +101,7 @@ def assign_process(
related_objects = list(operates_on.RelatedObjects)
related_objects.append(related_object)
operates_on.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": operates_on})
ifcopenshell.api.owner.update_owner_history(file, element=operates_on)
else:
operates_on = file.create_entity(
"IfcRelAssignsToProcess",
@@ -77,7 +77,7 @@ def assign_product(
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(related_object)
referenced_by.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(file, **{"element": referenced_by})
ifcopenshell.api.owner.update_owner_history(file, element=referenced_by)
else:
referenced_by = file.create_entity(
"IfcRelAssignsToProduct",
@@ -94,7 +94,7 @@ class Usecase:
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(related_object)
referenced_by.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
ifcopenshell.api.owner.update_owner_history(self.file, element=referenced_by)
else:
referenced_by = self.file.create_entity(
"IfcRelDefinesByObject",
@@ -166,7 +166,7 @@ class Usecase:
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(related_object)
referenced_by.RelatedObjects = related_objects
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
ifcopenshell.api.owner.update_owner_history(self.file, element=referenced_by)
else:
referenced_by = self.file.create_entity(
"IfcRelDefinesByObject",
@@ -139,7 +139,7 @@ def assign_container(
related_elements = set(rel.RelatedElements) - products_set
if related_elements:
rel.RelatedElements = list(related_elements)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -149,7 +149,7 @@ def assign_container(
# assign elements to a new container
if structure_rel:
structure_rel.RelatedElements = list(set(structure_rel.RelatedElements) | products_set)
ifcopenshell.api.owner.update_owner_history(file, **{"element": structure_rel})
ifcopenshell.api.owner.update_owner_history(file, element=structure_rel)
else:
structure_rel = file.create_entity(
"IfcRelContainedInSpatialStructure",
@@ -74,7 +74,7 @@ def dereference_structure(
related_elements = related_elements - products_set
if related_elements:
rel.RelatedElements = list(related_elements)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
@@ -64,7 +64,7 @@ def assign_flow_control(
related_flow_controls = set(assignment.RelatedControlElements)
related_flow_controls.add(related_flow_control)
assignment.RelatedControlElements = list(related_flow_controls)
ifcopenshell.api.owner.update_owner_history(file, **{"element": assignment})
ifcopenshell.api.owner.update_owner_history(file, element=assignment)
return assignment
assignment = file.create_entity(
@@ -83,7 +83,7 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set()
related_objects.add(self.port)
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
else:
rel = self.file.create_entity(
"IfcRelNests",
@@ -64,4 +64,4 @@ def unassign_flow_control(
related_flow_controls = list(assignment.RelatedControlElements)
related_flow_controls.remove(related_flow_control)
assignment.RelatedControlElements = related_flow_controls
ifcopenshell.api.owner.update_owner_history(file, **{"element": assignment})
ifcopenshell.api.owner.update_owner_history(file, element=assignment)
@@ -74,7 +74,7 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set()
related_objects.remove(port)
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(self.file, element=rel)
def execute_ifc2x3(self) -> None:
for rel in self.element.HasPorts or []:
@@ -228,7 +228,7 @@ class Usecase:
cur_related_objects = set(is_typed_by.RelatedObjects) - related_objects_set
if cur_related_objects:
is_typed_by.RelatedObjects = list(cur_related_objects)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": is_typed_by})
ifcopenshell.api.owner.update_owner_history(self.file, element=is_typed_by)
else:
history = is_typed_by.OwnerHistory
self.file.remove(is_typed_by)
@@ -238,7 +238,7 @@ class Usecase:
# assign objects to a new type
if types:
types.RelatedObjects = list(set(types.RelatedObjects) | related_objects_set)
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": types})
ifcopenshell.api.owner.update_owner_history(self.file, element=types)
else:
types = self.file.create_entity(
"IfcRelDefinesByType",
@@ -63,7 +63,7 @@ def unassign_type(file: ifcopenshell.file, related_objects: list[ifcopenshell.en
related_objects_set = set(rel.RelatedObjects) - related_objects_set
if related_objects_set:
rel.RelatedObjects = list(related_objects_set)
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)
else:
history = rel.OwnerHistory
file.remove(rel)
+1 -1
View File
@@ -326,7 +326,7 @@ class BCFDB(MyDB):
"reference": reference,
}
project_file_information = ProjectFileInformation(
**{"display_information": display_information_list, "file": file_get_json}
display_information=display_information_list, file=file_get_json
)
project_file_informations.append(project_file_information)
return project_file_informations
@@ -248,14 +248,12 @@ class DOCDB(MyDB):
raise HTTPException(status_code=400, detail="Document node was not created.")
session_init = DocumentUploadSessionInitialization(
**{
"upload_ui_url": os.environ["KONTROLL_BASE_URL"]
+ "documents/1.0/"
+ "document-upload?upload_session="
+ session_uuid,
"expires_in": os.environ["SESSION_URL_VALIDITY_SECONDS"],
"max_size_in_bytes": os.environ["SESSION_MAX_FILE_SIZE_BYTES"],
}
upload_ui_url=os.environ["KONTROLL_BASE_URL"]
+ "documents/1.0/"
+ "document-upload?upload_session="
+ session_uuid,
expires_in=os.environ["SESSION_URL_VALIDITY_SECONDS"],
max_size_in_bytes=os.environ["SESSION_MAX_FILE_SIZE_BYTES"],
)
return session_init
@@ -407,15 +405,13 @@ class DOCDB(MyDB):
upload_session_url = "?upload_session=" + upload_session
upload_complete_url = base_url + "upload-completion" + upload_session_url
upload_cancellation_url = base_url + "upload-cancellation" + upload_session_url
upload_completion = LinkData(**{"url": upload_complete_url})
upload_cancellation = LinkData(**{"url": upload_cancellation_url})
upload_completion = LinkData(url=upload_complete_url)
upload_cancellation = LinkData(url=upload_cancellation_url)
document_to_upload_model = DocumentToUpload(
**{
"session_file_id": document.session_file_id,
"upload_file_parts": list(),
"upload_completion": upload_completion,
"upload_cancellation": upload_cancellation,
}
session_file_id=document.session_file_id,
upload_file_parts=list(),
upload_completion=upload_completion,
upload_cancellation=upload_cancellation,
)
def add_part_work(tx) -> UUID:
@@ -461,14 +457,12 @@ class DOCDB(MyDB):
upload_part_url = "upload-part/" + str(upload_part_uuid)
additional_headers = {"values": [{"name": "Content-Length", "value": content_length}]}
part_instruction = UploadFilePartInstruction(
**{
"url": base_url + upload_part_url,
"http_method": "POST",
"additional_headers": additional_headers,
"include_authorization": True,
"content_range_start": content_range_start,
"content_range_end": content_range_end,
}
url=base_url + upload_part_url,
http_method="POST",
additional_headers=additional_headers,
include_authorization=True,
content_range_start=content_range_start,
content_range_end=content_range_end,
)
with self.driver.session() as session:
@@ -800,7 +794,7 @@ class DOCDB(MyDB):
MERGE (ss)-[r5:SELECTED]->(d)
"""
selected_documents_model = DocumentsMarkedAsSelected(**{"documents": list()})
selected_documents_model = DocumentsMarkedAsSelected(documents=list())
for document in all_documents:
result = tx.run(cypher, selection_session=str(selection_session), document_id=str(document))
@@ -823,13 +817,11 @@ class DOCDB(MyDB):
os.environ["KONTROLL_BASE_URL"] + "documents/1.0/document/" + document_id + "/version/" + str(version_index)
)
return DocumentVersionLinks(
**{
"document_version": LinkData(**{"url": base}),
"document_version_metadata": LinkData(**{"url": base + "/metadata"}),
"document_version_download": LinkData(**{"url": base + "/download"}),
"document_versions": LinkData(**{"url": base + "/versions"}),
"document_details": LinkData(**{"url": base + "/details"}),
}
document_version=LinkData(url=base),
document_version_metadata=LinkData(url=base + "/metadata"),
document_version_download=LinkData(url=base + "/download"),
document_versions=LinkData(url=base + "/versions"),
document_details=LinkData(url=base + "/details"),
)
def get_download_instructions(self, session_id: UUID, server_context: str, current_user: User) -> SelectedDocuments:
@@ -847,7 +839,7 @@ class DOCDB(MyDB):
document_model = self.document_node_to_model(document_node)
document_list.append(document_model)
selected_documents = SelectedDocuments(**{"server_context": server_context, "documents": document_list})
selected_documents = SelectedDocuments(server_context=server_context, documents=document_list)
return selected_documents
with self.driver.session() as session:
@@ -975,7 +967,7 @@ class DOCDB(MyDB):
"data_type": DataType.string,
}
entries.append(entry)
return DocumentMetadataEntries(**{"metadata": entries})
return DocumentMetadataEntries(metadata=entries)
with self.driver.session() as session:
return session.execute_read(get_document_version_metadata_work)