Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -17,42 +17,39 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
class Usecase:
def __init__(self, file, constituent=None):
"""Removes a constituent from a constituent set
def remove_constituent(file, constituent=None) -> None:
"""Removes a constituent from a constituent set
Note that it is invalid to have zero items in a set, so you should leave
at least one constituent to ensure a valid IFC dataset.
Note that it is invalid to have zero items in a set, so you should leave
at least one constituent to ensure a valid IFC dataset.
:param constituent: The IfcMaterialConstituent entity you want to remove
:type constituent: ifcopenshell.entity_instance
:return: None
:rtype: None
:param constituent: The IfcMaterialConstituent entity you want to remove
:type constituent: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
Example:
.. code:: python
.. code:: python
# Create a material set for windows made out of aluminium and glass.
material_set = ifcopenshell.api.run("material.add_material_set", model,
name="Window", set_type="IfcMaterialConstituentSet")
# Create a material set for windows made out of aluminium and glass.
material_set = ifcopenshell.api.run("material.add_material_set", model,
name="Window", set_type="IfcMaterialConstituentSet")
aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
# Now let's use those materials as two constituents in our set.
framing = ifcopenshell.api.run("material.add_constituent", model,
constituent_set=material_set, material=aluminium)
glazing = ifcopenshell.api.run("material.add_constituent", model,
constituent_set=material_set, material=glass)
# Now let's use those materials as two constituents in our set.
framing = ifcopenshell.api.run("material.add_constituent", model,
constituent_set=material_set, material=aluminium)
glazing = ifcopenshell.api.run("material.add_constituent", model,
constituent_set=material_set, material=glass)
# Let's remove the glass constituent. Note that we should not remove
# the framing, at this would mean there are no constituents which is
# invalid.
ifcopenshell.api.run("material.remove_constituent", model, constituent=glazing)
"""
self.file = file
self.settings = {"constituent": constituent}
# Let's remove the glass constituent. Note that we should not remove
# the framing, at this would mean there are no constituents which is
# invalid.
ifcopenshell.api.run("material.remove_constituent", model, constituent=glazing)
"""
settings = {"constituent": constituent}
def execute(self):
self.file.remove(self.settings["constituent"])
file.remove(settings["constituent"])