Fix #1462. Standardise IfcOpenShell API to use Pythonic argument names.

This commit is contained in:
Dion Moult
2021-05-28 10:59:20 +10:00
parent 0a2adbb632
commit 1cd243f13c
19 changed files with 119 additions and 114 deletions
@@ -269,7 +269,7 @@ class UpdateRepresentation(bpy.types.Operator):
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if product.is_a("IfcGridAxis"):
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": product})
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"axis_curve": obj, "grid_axis": product})
return
bpy.ops.bim.edit_object_placement(obj=obj.name)
@@ -42,7 +42,7 @@ class AddMaterial(bpy.types.Operator):
def execute(self, context):
obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material
self.file = IfcStore.get_file()
result = ifcopenshell.api.run("material.add_material", self.file, **{"Name": obj.name})
result = ifcopenshell.api.run("material.add_material", self.file, **{"name": obj.name})
obj.BIMObjectProperties.ifc_definition_id = result.id()
Data.load(IfcStore.get_file())
material_prop_purge()
@@ -57,10 +57,10 @@ def add_object(self, context):
result = ifcopenshell.api.run(
"grid.create_grid_axis",
self.file,
**{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "UAxes", "Grid": grid},
**{"axis_tag": tag, "uvw_axes": "UAxes", "grid": grid},
)
IfcStore.link_element(result, obj)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"axis_curve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id()
axes_collection = bpy.data.collections.new("VAxes")
@@ -83,10 +83,10 @@ def add_object(self, context):
result = ifcopenshell.api.run(
"grid.create_grid_axis",
self.file,
**{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "VAxes", "Grid": grid},
**{"axis_tag": tag, "uvw_axes": "VAxes", "grid": grid},
)
IfcStore.link_element(result, obj)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"axis_curve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id()
@@ -729,8 +729,8 @@ class DumbWallGenerator:
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcWall")
bpy.ops.bim.assign_type(relating_type=self.relating_type.id(), related_object=obj.name)
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, Name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, Properties={"Engine": "BlenderBIM.DumbWall"})
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Engine": "BlenderBIM.DumbWall"})
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage")
MaterialData.load(self.file)
return obj
@@ -78,7 +78,7 @@ def calculate_dumb_quantities(usecase_path, ifc_file, **settings):
if not parametric or parametric["Engine"] != "BlenderBIM.DumbWall":
return
qto = ifcopenshell.api.run(
"pset.add_qto", ifc_file, should_run_listeners=False, product=product, Name="Qto_WallBaseQuantities"
"pset.add_qto", ifc_file, should_run_listeners=False, product=product, name="Qto_WallBaseQuantities"
)
length = obj.dimensions[0] / unit_scale
width = obj.dimensions[1] / unit_scale
@@ -95,7 +95,7 @@ def calculate_dumb_quantities(usecase_path, ifc_file, **settings):
net_volume = gross_volume
bm.free()
ifcopenshell.api.run("pset.edit_qto", ifc_file, should_run_listeners=False, qto=qto, Properties={
ifcopenshell.api.run("pset.edit_qto", ifc_file, should_run_listeners=False, qto=qto, properties={
"Length": round(length, 2),
"Width": round(width, 2),
"Height": round(height, 2),
@@ -187,8 +187,8 @@ class EditPset(bpy.types.Operator):
self.file,
**{
"pset": self.file.by_id(pset_id),
"Name": props.active_pset_name,
"Properties": properties,
"name": props.active_pset_name,
"properties": properties,
},
)
else:
@@ -197,8 +197,8 @@ class EditPset(bpy.types.Operator):
self.file,
**{
"qto": self.file.by_id(pset_id),
"Name": props.active_pset_name,
"Properties": properties,
"name": props.active_pset_name,
"properties": properties,
},
)
Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
@@ -260,7 +260,7 @@ class AddPset(bpy.types.Operator):
self.file,
**{
"product": self.file.by_id(oprops.ifc_definition_id),
"Name": pset_name,
"name": pset_name,
},
)
Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
@@ -281,7 +281,7 @@ class AddQto(bpy.types.Operator):
self.file,
**{
"product": self.file.by_id(oprops.ifc_definition_id),
"Name": props.qto_name,
"name": props.qto_name,
},
)
Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
@@ -99,13 +99,13 @@ class QuantifyObjects(bpy.types.Operator):
"pset.add_qto",
self.file,
product=self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
Name=props.qto_name,
name=props.qto_name,
)
ifcopenshell.api.run(
"pset.edit_qto",
self.file,
qto=qto,
Properties={props.prop_name: result}
properties={props.prop_name: result}
)
PsetData.load(self.file, obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"}
@@ -11,9 +11,9 @@ def get_colour_settings(material):
transparency = bsdf.inputs["Alpha"].default_value
diffuse_colour = bsdf.inputs["Base Color"].default_value
return {
"SurfaceColour": tuple(material.diffuse_color),
"Transparency": transparency,
"DiffuseColour": tuple(diffuse_colour),
"surface_colour": tuple(material.diffuse_color),
"transparency": transparency,
"diffuse_colour": tuple(diffuse_colour),
}
@@ -40,7 +40,7 @@ class AddStyle(bpy.types.Operator):
self.file = IfcStore.get_file()
material = bpy.data.materials.get(self.material) if self.material else bpy.context.active_object.active_material
settings = get_colour_settings(material)
settings["Name"] = material.name
settings["name"] = material.name
settings["external_definition"] = None # TODO: Implement. See #1222
style = ifcopenshell.api.run("style.add_style", self.file, **settings)
material.BIMMaterialProperties.ifc_style_id = int(style.id())