mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -17,36 +17,33 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, prop_template=None, attributes=None):
|
||||
"""Edits the attributes of an IfcSimplePropertyTemplate
|
||||
def edit_prop_template(file, prop_template=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcSimplePropertyTemplate
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcSimplePropertyTemplate, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcSimplePropertyTemplate, consult the IFC documentation.
|
||||
|
||||
:param prop_template: The IfcSimplePropertyTemplate entity you want to edit
|
||||
:type prop_template: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
:param prop_template: The IfcSimplePropertyTemplate entity you want to edit
|
||||
:type prop_template: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
|
||||
template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
|
||||
|
||||
# Here's a property with just default values.
|
||||
prop = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template)
|
||||
# Here's a property with just default values.
|
||||
prop = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template)
|
||||
|
||||
# Let's edit it to give the actual values we need.
|
||||
ifcopenshell.api.run("pset_template.edit_prop_template", model,
|
||||
prop_template=prop, attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLengthMeasure"})
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"prop_template": prop_template, "attributes": attributes or {}}
|
||||
# Let's edit it to give the actual values we need.
|
||||
ifcopenshell.api.run("pset_template.edit_prop_template", model,
|
||||
prop_template=prop, attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLengthMeasure"})
|
||||
"""
|
||||
settings = {"prop_template": prop_template, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["prop_template"], name, value)
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["prop_template"], name, value)
|
||||
|
||||
Reference in New Issue
Block a user