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,
)