mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 19:54:07 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -17,31 +17,28 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, objective=None, attributes=None):
|
||||
"""Edit the attributes of a objective
|
||||
def edit_objective(file, objective=None, attributes=None) -> None:
|
||||
"""Edit the attributes of a objective
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcObjective, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcObjective, consult the IFC documentation.
|
||||
|
||||
:param objective: The IfcObjective you want to edit.
|
||||
:type objective: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
:param objective: The IfcObjective you want to edit.
|
||||
:type objective: 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
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
ifcopenshell.api.run("constraint.edit_objective", model,
|
||||
objective=objective, attributes={"ConstraintGrade": "HARD"})
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"objective": objective, "attributes": attributes or {}}
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
ifcopenshell.api.run("constraint.edit_objective", model,
|
||||
objective=objective, attributes={"ConstraintGrade": "HARD"})
|
||||
"""
|
||||
settings = {"objective": objective, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["objective"], name, value)
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["objective"], name, value)
|
||||
|
||||
Reference in New Issue
Block a user