mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
typing
This commit is contained in:
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def add_layer(file, Name=None) -> None:
|
def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new layer
|
"""Adds a new layer
|
||||||
|
|
||||||
An IFC layer is like a CAD layer. Portions of an object's geometry
|
An IFC layer is like a CAD layer. Portions of an object's geometry
|
||||||
@@ -41,6 +43,4 @@ def add_layer(file, Name=None) -> None:
|
|||||||
|
|
||||||
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
|
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
|
||||||
"""
|
"""
|
||||||
settings = {"Name": Name or "Unnamed"}
|
return file.create_entity("IfcPresentationLayerAssignment", Name=Name)
|
||||||
|
|
||||||
return file.create_entity("IfcPresentationLayerAssignment", Name=settings["Name"])
|
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_layer(file, layer=None, attributes=None) -> None:
|
def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcPresentationLayerAssignment
|
"""Edits the attributes of an IfcPresentationLayerAssignment
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
|
|||||||
:param layer: The IfcPresentationLayerAssignment entity you want to edit
|
:param layer: The IfcPresentationLayerAssignment entity you want to edit
|
||||||
:type layer: ifcopenshell.entity_instance
|
:type layer: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("layer.edit_layer", model,
|
ifcopenshell.api.run("layer.edit_layer", model,
|
||||||
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
|
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
|
||||||
"""
|
"""
|
||||||
settings = {"layer": layer, "attributes": attributes or {}}
|
settings = {"layer": layer, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["layer"], name, value)
|
setattr(settings["layer"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_layer(file, layer=None) -> None:
|
def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a layer
|
"""Removes a layer
|
||||||
|
|
||||||
All representation items assigned to the layer will remain, but the
|
All representation items assigned to the layer will remain, but the
|
||||||
@@ -35,6 +36,4 @@ def remove_layer(file, layer=None) -> None:
|
|||||||
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
||||||
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
|
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
|
||||||
"""
|
"""
|
||||||
settings = {"layer": layer}
|
file.remove(layer)
|
||||||
|
|
||||||
file.remove(settings["layer"])
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell.util.schema
|
|||||||
import ifcopenshell.util.date
|
import ifcopenshell.util.date
|
||||||
|
|
||||||
|
|
||||||
def add_library(file, name=None) -> None:
|
def add_library(file: ifcopenshell.entity_instance, name: str) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new library to the project
|
"""Adds a new library to the project
|
||||||
|
|
||||||
A library is an external data source that is related to the project. It
|
A library is an external data source that is related to the project. It
|
||||||
@@ -60,6 +60,4 @@ def add_library(file, name=None) -> None:
|
|||||||
|
|
||||||
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||||
"""
|
"""
|
||||||
settings = {"name": name}
|
return file.create_entity("IfcLibraryInformation", Name=name)
|
||||||
|
|
||||||
return file.create_entity("IfcLibraryInformation", Name=settings["name"])
|
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_library(file, library=None, attributes=None) -> None:
|
def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcLibraryInformation
|
"""Edits the attributes of an IfcLibraryInformation
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_library(file, library=None, attributes=None) -> None:
|
|||||||
:param library: The IfcLibraryInformation entity you want to edit
|
:param library: The IfcLibraryInformation entity you want to edit
|
||||||
:type library: ifcopenshell.entity_instance
|
:type library: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ def edit_library(file, library=None, attributes=None) -> None:
|
|||||||
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
|
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
|
||||||
"""
|
"""
|
||||||
|
|
||||||
settings = {"library": library, "attributes": attributes or {}}
|
settings = {"library": library, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["library"], name, value)
|
setattr(settings["library"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,13 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_reference(file, reference=None, attributes=None) -> None:
|
def edit_reference(
|
||||||
|
file: ifcopenshell.file, reference: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||||
|
) -> None:
|
||||||
"""Edits the attributes of an IfcLibraryReference
|
"""Edits the attributes of an IfcLibraryReference
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +30,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
|
|||||||
:param reference: The IfcLibraryReference entity you want to edit
|
:param reference: The IfcLibraryReference entity you want to edit
|
||||||
:type reference: ifcopenshell.entity_instance
|
:type reference: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -40,7 +44,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("library.edit_reference", model,
|
ifcopenshell.api.run("library.edit_reference", model,
|
||||||
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
||||||
"""
|
"""
|
||||||
settings = {"reference": reference, "attributes": attributes or {}}
|
settings = {"reference": reference, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["reference"], name, value)
|
setattr(settings["reference"], name, value)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_library(file, library=None) -> None:
|
def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a library
|
"""Removes a library
|
||||||
|
|
||||||
All references along with their relationships will also be removed. Any
|
All references along with their relationships will also be removed. Any
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_constituent(file, constituent_set=None, material=None) -> None:
|
def add_constituent(
|
||||||
|
file: ifcopenshell.file, constituent_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new constituent to a constituent set
|
"""Adds a new constituent to a constituent set
|
||||||
|
|
||||||
A constituent describes how a portion of an object is made out of a
|
A constituent describes how a portion of an object is made out of a
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_layer(file, layer_set=None, material=None) -> None:
|
def add_layer(
|
||||||
|
file: ifcopenshell.file, layer_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new layer to a layer set
|
"""Adds a new layer to a layer set
|
||||||
|
|
||||||
A layer represents a portion of material within a layered build up,
|
A layer represents a portion of material within a layered build up,
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_list_item(file, material_list=None, material=None) -> None:
|
def add_list_item(
|
||||||
|
file: ifcopenshell.file, material_list: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
|
||||||
|
) -> None:
|
||||||
"""Adds a new material in a list of materials
|
"""Adds a new material in a list of materials
|
||||||
|
|
||||||
In IFC2X3, if you wanted an object to have multiple materials (i.e. a
|
In IFC2X3, if you wanted an object to have multiple materials (i.e. a
|
||||||
|
|||||||
@@ -15,9 +15,13 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def add_material(file, name=None, category=None) -> None:
|
def add_material(
|
||||||
|
file: ifcopenshell.file, name: Optional[str] = None, category: Optional[str] = None
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new material
|
"""Adds a new material
|
||||||
|
|
||||||
A material in IFC represents a physical material, such as timber, steel,
|
A material in IFC represents a physical material, such as timber, steel,
|
||||||
@@ -48,7 +52,7 @@ def add_material(file, name=None, category=None) -> None:
|
|||||||
|
|
||||||
:param name: The name of the material, typically tagged in a finishes
|
:param name: The name of the material, typically tagged in a finishes
|
||||||
drawing or schedule.
|
drawing or schedule.
|
||||||
:type name: str
|
:type name: str, optional
|
||||||
:param category: The category of the material.
|
:param category: The category of the material.
|
||||||
:type category: str, optional
|
:type category: str, optional
|
||||||
:return: The newly created IfcMaterial
|
:return: The newly created IfcMaterial
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_material_set(file, name="Unnamed", set_type="IfcMaterialConstituentSet") -> None:
|
def add_material_set(
|
||||||
|
file: ifcopenshell.file, name: str = "Unnamed", set_type: str = "IfcMaterialConstituentSet"
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new material set
|
"""Adds a new material set
|
||||||
|
|
||||||
IFC allows you to state that objects are made out of multiple materials.
|
IFC allows you to state that objects are made out of multiple materials.
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
|
|
||||||
|
|
||||||
def assign_profile(file, material_profile=None, profile=None) -> None:
|
def assign_profile(
|
||||||
|
file: ifcopenshell.file, material_profile: ifcopenshell.entity_instance, profile: ifcopenshell.entity_instance
|
||||||
|
) -> None:
|
||||||
"""Changes the profile curve of a material profile item in a profile set
|
"""Changes the profile curve of a material profile item in a profile set
|
||||||
|
|
||||||
In addition to changing the profile curve, it will also change the
|
In addition to changing the profile curve, it will also change the
|
||||||
@@ -94,7 +96,8 @@ def assign_profile(file, material_profile=None, profile=None) -> None:
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def execute(self):
|
file: ifcopenshell.file
|
||||||
|
def execute(self) -> None:
|
||||||
# TODO: handle composite profiles
|
# TODO: handle composite profiles
|
||||||
old_profile = self.settings["material_profile"].Profile
|
old_profile = self.settings["material_profile"].Profile
|
||||||
self.settings["material_profile"].Profile = self.settings["profile"]
|
self.settings["material_profile"].Profile = self.settings["profile"]
|
||||||
@@ -117,7 +120,7 @@ class Usecase:
|
|||||||
# TODO: check remove deep
|
# TODO: check remove deep
|
||||||
self.file.remove(old_profile)
|
self.file.remove(old_profile)
|
||||||
|
|
||||||
def change_profile(self, element):
|
def change_profile(self, element: ifcopenshell.entity_instance) -> None:
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
if not representation:
|
if not representation:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def copy_material(file, material=None) -> None:
|
def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||||
"""Copies a material
|
"""Copies a material
|
||||||
|
|
||||||
All material psets and styles are copied. The copied material is not
|
All material psets and styles are copied. The copied material is not
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_assigned_material(file, element=None, attributes=None) -> None:
|
def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcMaterial
|
"""Edits the attributes of an IfcMaterial
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_assigned_material(file, element=None, attributes=None) -> None:
|
|||||||
:param element: The IfcMaterial entity you want to edit
|
:param element: The IfcMaterial entity you want to edit
|
||||||
:type element: ifcopenshell.entity_instance
|
:type element: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ def edit_assigned_material(file, element=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("material.edit_assigned_material", model,
|
ifcopenshell.api.run("material.edit_assigned_material", model,
|
||||||
element=concrete, attributes={"Description": "40MPA concrete with broom finish"})
|
element=concrete, attributes={"Description": "40MPA concrete with broom finish"})
|
||||||
"""
|
"""
|
||||||
settings = {"element": element, "attributes": attributes or {}}
|
settings = {"element": element, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["element"], name, value)
|
setattr(settings["element"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,16 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Optional, Any
|
||||||
|
|
||||||
|
|
||||||
def edit_constituent(file, constituent=None, attributes=None, material=None) -> None:
|
def edit_constituent(
|
||||||
|
file: ifcopenshell.file,
|
||||||
|
constituent: ifcopenshell.entity_instance,
|
||||||
|
attributes: Optional[dict[str, Any]] = None,
|
||||||
|
material: Optional[ifcopenshell.entity_instance] = None,
|
||||||
|
) -> None:
|
||||||
"""Edits the attributes of an IfcMaterialConstituent
|
"""Edits the attributes of an IfcMaterialConstituent
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
|
|||||||
@@ -15,9 +15,16 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Optional, Any
|
||||||
|
|
||||||
|
|
||||||
def edit_layer(file, layer=None, attributes=None, material=None) -> None:
|
def edit_layer(
|
||||||
|
file: ifcopenshell.file,
|
||||||
|
layer: ifcopenshell.entity_instance,
|
||||||
|
attributes: Optional[dict[str, Any]] = None,
|
||||||
|
material: Optional[ifcopenshell.entity_instance] = None,
|
||||||
|
) -> None:
|
||||||
"""Edits the attributes of an IfcMaterialLayer
|
"""Edits the attributes of an IfcMaterialLayer
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_layer_usage(file, usage=None, attributes=None) -> None:
|
def edit_layer_usage(file: ifcopenshell.file, usage: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcMaterialLayerSetUsage
|
"""Edits the attributes of an IfcMaterialLayerSetUsage
|
||||||
|
|
||||||
This is typically used to change the offset from the reference line to
|
This is typically used to change the offset from the reference line to
|
||||||
@@ -29,7 +31,7 @@ def edit_layer_usage(file, usage=None, attributes=None) -> None:
|
|||||||
:param usage: The IfcMaterialLayerSetUsage entity you want to edit
|
:param usage: The IfcMaterialLayerSetUsage entity you want to edit
|
||||||
:type usage: ifcopenshell.entity_instance
|
:type usage: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ def edit_layer_usage(file, usage=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("material.edit_layer_usage", model,
|
ifcopenshell.api.run("material.edit_layer_usage", model,
|
||||||
usage=rel.RelatingMaterial, attributes={"OffsetFromReferenceLine": 200})
|
usage=rel.RelatingMaterial, attributes={"OffsetFromReferenceLine": 200})
|
||||||
"""
|
"""
|
||||||
settings = {"usage": usage, "attributes": attributes or {}}
|
settings = {"usage": usage, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["usage"], name, value)
|
setattr(settings["usage"], name, value)
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_material(file, material=None, attributes=None) -> None:
|
def edit_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcMaterial"""
|
"""Edits the attributes of an IfcMaterial"""
|
||||||
|
|
||||||
settings = {"material": material, "attributes": attributes or {}}
|
for name, value in attributes.items():
|
||||||
|
setattr(material, name, value)
|
||||||
for name, value in settings["attributes"].items():
|
|
||||||
setattr(settings["material"], name, value)
|
|
||||||
|
|||||||
@@ -17,7 +17,17 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
def edit_profile(file, profile=None, attributes=None, profile_def=None, material=None) -> None:
|
from typing import Any, Optional
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
|
def edit_profile(
|
||||||
|
file: ifcopenshell.file,
|
||||||
|
profile: ifcopenshell.entity_instance,
|
||||||
|
attributes: Optional[dict[str, Any]] = None,
|
||||||
|
profile_def: Optional[ifcopenshell.entity_instance] = None,
|
||||||
|
material: Optional[ifcopenshell.entity_instance] = None,
|
||||||
|
) -> None:
|
||||||
"""Edits the attributes of an IfcMaterialProfile
|
"""Edits the attributes of an IfcMaterialProfile
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_profile_usage(file, usage=None, attributes=None) -> None:
|
def edit_profile_usage(
|
||||||
|
file: ifcopenshell.file, usage: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||||
|
) -> None:
|
||||||
"""Edits the attributes of an IfcMaterialProfileSetUsage
|
"""Edits the attributes of an IfcMaterialProfileSetUsage
|
||||||
|
|
||||||
This is typically used to change the cardinal point of the profile.
|
This is typically used to change the cardinal point of the profile.
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_constituent(file, constituent=None) -> None:
|
def remove_constituent(file: ifcopenshell.file, constituent: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a constituent from a constituent set
|
"""Removes a constituent from a constituent set
|
||||||
|
|
||||||
Note that it is invalid to have zero items in a set, so you should leave
|
Note that it is invalid to have zero items in a set, so you should leave
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_layer(file, layer=None) -> None:
|
def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a layer from a layer set
|
"""Removes a layer from a layer set
|
||||||
|
|
||||||
Note that it is invalid to have zero items in a set, so you should leave
|
Note that it is invalid to have zero items in a set, so you should leave
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_list_item(file, material_list=None, material_index=0) -> None:
|
def remove_list_item(
|
||||||
|
file: ifcopenshell.file, material_list: ifcopenshell.entity_instance, material_index: int = 0
|
||||||
|
) -> None:
|
||||||
"""Removes an item in an material list
|
"""Removes an item in an material list
|
||||||
|
|
||||||
Note that it is invalid to have zero items in a list, so you should leave
|
Note that it is invalid to have zero items in a list, so you should leave
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_material(file, material=None) -> None:
|
def remove_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a material
|
"""Removes a material
|
||||||
|
|
||||||
If the material is used in a material set, the corresponding layer,
|
If the material is used in a material set, the corresponding layer,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_material_set(file, material=None) -> None:
|
def remove_material_set(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a material set
|
"""Removes a material set
|
||||||
|
|
||||||
All set items, such as layers, profiles, or constituents will also be
|
All set items, such as layers, profiles, or constituents will also be
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_profile(file, profile=None) -> None:
|
def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a profile item from a profile set
|
"""Removes a profile item from a profile set
|
||||||
|
|
||||||
Note that it is invalid to have zero items in a set, so you should leave
|
Note that it is invalid to have zero items in a set, so you should leave
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def reorder_set_item(file, material_set=None, old_index=0, new_index=0) -> None:
|
def reorder_set_item(
|
||||||
|
file: ifcopenshell.file, material_set: ifcopenshell.entity_instance, old_index: int = 0, new_index: int = 0
|
||||||
|
) -> None:
|
||||||
"""Reorders an item in a material set
|
"""Reorders an item in a material set
|
||||||
|
|
||||||
In some material sets, the order have meaning, like in a layer set. In
|
In some material sets, the order have meaning, like in a layer set. In
|
||||||
|
|||||||
@@ -21,15 +21,15 @@ import ifcopenshell.api
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def change_nest(file, item=None, new_parent=None) -> None:
|
def change_nest(
|
||||||
|
file: ifcopenshell.file, item: ifcopenshell.entity_instance, new_parent: ifcopenshell.entity_instance
|
||||||
|
) -> None:
|
||||||
"""Assigns a cost item to a new parent cost item"""
|
"""Assigns a cost item to a new parent cost item"""
|
||||||
settings = {"item": item, "new_parent": new_parent}
|
if not item.Nests:
|
||||||
|
|
||||||
if not settings["item"].Nests:
|
|
||||||
return
|
return
|
||||||
nests = settings["item"].Nests[0]
|
nests = item.Nests[0]
|
||||||
related_objects = list(nests.RelatedObjects)
|
related_objects = list(nests.RelatedObjects)
|
||||||
related_objects.remove(settings["item"])
|
related_objects.remove(item)
|
||||||
if related_objects:
|
if related_objects:
|
||||||
nests.RelatedObjects = related_objects
|
nests.RelatedObjects = related_objects
|
||||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": nests})
|
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": nests})
|
||||||
@@ -41,6 +41,6 @@ def change_nest(file, item=None, new_parent=None) -> None:
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"nest.assign_object",
|
"nest.assign_object",
|
||||||
file,
|
file,
|
||||||
related_objects=[settings["item"]],
|
related_objects=[item],
|
||||||
relating_object=settings["new_parent"],
|
relating_object=new_parent,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,19 +15,18 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def reorder_nesting(file, item=None, old_index=0, new_index=0) -> None:
|
def reorder_nesting(
|
||||||
|
file: ifcopenshell.file, item: ifcopenshell.entity_instance, old_index: int = 0, new_index: int = 0
|
||||||
|
) -> None:
|
||||||
"""Reorders an item in a nesting set"""
|
"""Reorders an item in a nesting set"""
|
||||||
settings = {"item": item, "old_index": old_index, "new_index": new_index}
|
if not item.Nests:
|
||||||
|
|
||||||
if not settings["item"].Nests:
|
|
||||||
return
|
return
|
||||||
nesting_set = settings["item"].Nests[0]
|
nesting_set = item.Nests[0]
|
||||||
if not settings["old_index"]:
|
if not old_index:
|
||||||
old_index = nesting_set.RelatedObjects.index(settings["item"])
|
old_index = nesting_set.RelatedObjects.index(item)
|
||||||
else:
|
|
||||||
old_index = settings["old_index"]
|
|
||||||
items = list(getattr(nesting_set, "RelatedObjects") or [])
|
items = list(getattr(nesting_set, "RelatedObjects") or [])
|
||||||
items.insert(settings["new_index"], items.pop(old_index))
|
items.insert(new_index, items.pop(old_index))
|
||||||
setattr(nesting_set, "RelatedObjects", items)
|
setattr(nesting_set, "RelatedObjects", items)
|
||||||
|
|||||||
@@ -19,9 +19,14 @@
|
|||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
|
||||||
def add_actor(file, actor=None, ifc_class="IfcActor") -> None:
|
def add_actor(
|
||||||
|
file: ifcopenshell.file,
|
||||||
|
actor: ifcopenshell.entity_instance,
|
||||||
|
ifc_class: Literal["IfcActor", "IfcOccupant"] = "IfcActor",
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new actor
|
"""Adds a new actor
|
||||||
|
|
||||||
An actor is a person or an organisation who has a responsibility or role
|
An actor is a person or an organisation who has a responsibility or role
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_address(file, assigned_object=None, ifc_class="IfcPostalAddress") -> None:
|
def add_address(
|
||||||
|
file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, ifc_class: str = "IfcPostalAddress"
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Add a new telecom or postal address to an organisation or person
|
"""Add a new telecom or postal address to an organisation or person
|
||||||
|
|
||||||
A person or organisation may have associated contact details such as
|
A person or organisation may have associated contact details such as
|
||||||
|
|||||||
@@ -17,15 +17,16 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def add_application(
|
def add_application(
|
||||||
file,
|
file: ifcopenshell.file,
|
||||||
application_developer=None,
|
application_developer: Optional[ifcopenshell.entity_instance] = None,
|
||||||
version=None,
|
version: Optional[str] = None,
|
||||||
application_full_name="IfcOpenShell",
|
application_full_name: str = "IfcOpenShell",
|
||||||
application_identifier="IfcOpenShell",
|
application_identifier: str = "IfcOpenShell",
|
||||||
) -> None:
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new application
|
"""Adds a new application
|
||||||
|
|
||||||
IFC data may be associated with an authoring application to identify
|
IFC data may be associated with an authoring application to identify
|
||||||
@@ -46,6 +47,8 @@ def add_application(
|
|||||||
:param application_identifier: An identification string for the
|
:param application_identifier: An identification string for the
|
||||||
application intended for computers to read.
|
application intended for computers to read.
|
||||||
:type application_identifier: str, optional
|
:type application_identifier: str, optional
|
||||||
|
:return: The newly created IfcApplication
|
||||||
|
:rtype: ifcopenshell.entity_instance
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def add_person(
|
|||||||
identification: str = "HSeldon",
|
identification: str = "HSeldon",
|
||||||
family_name: str = "Seldon",
|
family_name: str = "Seldon",
|
||||||
given_name: str = "Hari",
|
given_name: str = "Hari",
|
||||||
) -> None:
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new person
|
"""Adds a new person
|
||||||
|
|
||||||
Persons are used to identify a legal or liable representative of an
|
Persons are used to identify a legal or liable representative of an
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
|
def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT") -> ifcopenshell.entity_instance:
|
||||||
"""Adds and assigns a new role
|
"""Adds and assigns a new role
|
||||||
|
|
||||||
People and organisations must play one or more roles on a project. Roles
|
People and organisations must play one or more roles on a project. Roles
|
||||||
@@ -32,7 +33,7 @@ def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
|
|||||||
be assigned to.
|
be assigned to.
|
||||||
:type assigned_object: ifcopenshell.entity_instance
|
:type assigned_object: ifcopenshell.entity_instance
|
||||||
:param role: The type of role, taken from the IFC documentation for
|
:param role: The type of role, taken from the IFC documentation for
|
||||||
IfcActorRole, or a custom name.
|
IfcActorRole, or a custom name. Defaults to "ARCHITECT".
|
||||||
:type role: str, optional
|
:type role: str, optional
|
||||||
:return: The newly created IfcActorRole
|
:return: The newly created IfcActorRole
|
||||||
:rtype: ifcopenshell.entity_instance
|
:rtype: ifcopenshell.entity_instance
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import ifcopenshell.api
|
|||||||
import ifcopenshell.guid
|
import ifcopenshell.guid
|
||||||
|
|
||||||
|
|
||||||
def assign_actor(file, relating_actor=None, related_object=None) -> None:
|
def assign_actor(
|
||||||
|
file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Assigns an actor to an object
|
"""Assigns an actor to an object
|
||||||
|
|
||||||
An actor may be assigned to objects which implies that the actor is
|
An actor may be assigned to objects which implies that the actor is
|
||||||
@@ -80,7 +82,7 @@ def assign_actor(file, relating_actor=None, related_object=None) -> None:
|
|||||||
if settings["related_object"].HasAssignments:
|
if settings["related_object"].HasAssignments:
|
||||||
for rel in settings["related_object"].HasAssignments:
|
for rel in settings["related_object"].HasAssignments:
|
||||||
if rel.is_a("IfcRelAssignsToActor") and rel.RelatingActor == settings["relating_actor"]:
|
if rel.is_a("IfcRelAssignsToActor") and rel.RelatingActor == settings["relating_actor"]:
|
||||||
return
|
return rel
|
||||||
|
|
||||||
rel = None
|
rel = None
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_actor(file, actor=None, attributes=None) -> None:
|
def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcActor
|
"""Edits the attributes of an IfcActor
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
|
|||||||
:param actor: The IfcActor entity you want to edit
|
:param actor: The IfcActor entity you want to edit
|
||||||
:type actor: ifcopenshell.entity_instance
|
:type actor: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("actor.edit_actor", model,
|
ifcopenshell.api.run("actor.edit_actor", model,
|
||||||
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
|
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
|
||||||
"""
|
"""
|
||||||
settings = {"actor": actor, "attributes": attributes or {}}
|
settings = {"actor": actor, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["actor"], name, value)
|
setattr(settings["actor"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_address(file, address=None, attributes=None) -> None:
|
def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcAddress
|
"""Edits the attributes of an IfcAddress
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_address(file, address=None, attributes=None) -> None:
|
|||||||
:param address: The IfcAddress entity you want to edit
|
:param address: The IfcAddress entity you want to edit
|
||||||
:type address: ifcopenshell.entity_instance
|
:type address: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ def edit_address(file, address=None, attributes=None) -> None:
|
|||||||
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
||||||
"WWWHomePageURL": "https://thinkmoult.com"})
|
"WWWHomePageURL": "https://thinkmoult.com"})
|
||||||
"""
|
"""
|
||||||
settings = {"address": address, "attributes": attributes or {}}
|
settings = {"address": address, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["address"], name, value)
|
setattr(settings["address"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_organisation(file, organisation=None, attributes=None) -> None:
|
def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcOrganization
|
"""Edits the attributes of an IfcOrganization
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
|
|||||||
:param organisation: The IfcOrganization entity you want to edit
|
:param organisation: The IfcOrganization entity you want to edit
|
||||||
:type organisation: ifcopenshell.entity_instance
|
:type organisation: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
|
ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
|
||||||
attributes={"name": "Architects Without Ballpens"})
|
attributes={"name": "Architects Without Ballpens"})
|
||||||
"""
|
"""
|
||||||
settings = {"organisation": organisation, "attributes": attributes or {}}
|
settings = {"organisation": organisation, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["organisation"], name, value)
|
setattr(settings["organisation"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_person(file, person=None, attributes=None) -> None:
|
def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcPerson
|
"""Edits the attributes of an IfcPerson
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_person(file, person=None, attributes=None) -> None:
|
|||||||
:param person: The IfcPerson entity you want to edit
|
:param person: The IfcPerson entity you want to edit
|
||||||
:type person: ifcopenshell.entity_instance
|
:type person: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ def edit_person(file, person=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("owner.edit_person", model, person=person,
|
ifcopenshell.api.run("owner.edit_person", model, person=person,
|
||||||
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
|
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
|
||||||
"""
|
"""
|
||||||
settings = {"person": person, "attributes": attributes or {}}
|
settings = {"person": person, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["person"], name, value)
|
setattr(settings["person"], name, value)
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_role(file, role=None, attributes=None) -> None:
|
def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcActorRole
|
"""Edits the attributes of an IfcActorRole
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_role(file, role=None, attributes=None) -> None:
|
|||||||
:param role: The IfcActorRole entity you want to edit
|
:param role: The IfcActorRole entity you want to edit
|
||||||
:type role: ifcopenshell.entity_instance
|
:type role: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ def edit_role(file, role=None, attributes=None) -> None:
|
|||||||
# But Bob is not an architect
|
# But Bob is not an architect
|
||||||
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
||||||
"""
|
"""
|
||||||
settings = {"role": role, "attributes": attributes or {}}
|
settings = {"role": role, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["role"], name, value)
|
setattr(settings["role"], name, value)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_actor(file, actor=None) -> None:
|
def remove_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes an actor
|
"""Removes an actor
|
||||||
|
|
||||||
:param actor: The IfcActor to remove.
|
:param actor: The IfcActor to remove.
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_address(file, address=None) -> None:
|
def remove_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes an address
|
"""Removes an address
|
||||||
|
|
||||||
Naturally, any organisations or people using that address will have the
|
Naturally, any organisations or people using that address will have the
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_application(file, application=None) -> None:
|
def remove_application(file: ifcopenshell.file, application: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes an application
|
"""Removes an application
|
||||||
|
|
||||||
Warning: removing an application may invalidate ownership histories.
|
Warning: removing an application may invalidate ownership histories.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
def remove_organisation(file, organisation=None) -> None:
|
def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance) -> None:
|
||||||
"""Remove an organisation
|
"""Remove an organisation
|
||||||
|
|
||||||
All roles and addresses assigned to the organisation will also be
|
All roles and addresses assigned to the organisation will also be
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
def remove_person(file, person=None) -> None:
|
def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance) -> None:
|
||||||
"""Remove an person
|
"""Remove an person
|
||||||
|
|
||||||
All roles and addresses assigned to the person will also be
|
All roles and addresses assigned to the person will also be
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
def remove_person_and_organisation(file, person_and_organisation=None) -> None:
|
def remove_person_and_organisation(
|
||||||
|
file: ifcopenshell.file, person_and_organisation: ifcopenshell.entity_instance
|
||||||
|
) -> None:
|
||||||
"""Removes a person and organisation
|
"""Removes a person and organisation
|
||||||
|
|
||||||
Note that the underlying person and organisation is not removed, only
|
Note that the underlying person and organisation is not removed, only
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def remove_role(file, role=None) -> None:
|
def remove_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a role
|
"""Removes a role
|
||||||
|
|
||||||
People and organisations using the role will be untouched. This may
|
People and organisations using the role will be untouched. This may
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import ifcopenshell.api
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
def unassign_actor(
|
||||||
|
file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
|
||||||
|
) -> None:
|
||||||
"""Unassigns an actor to an object
|
"""Unassigns an actor to an object
|
||||||
|
|
||||||
This means that the actor is no longer responsible for the object.
|
This means that the actor is no longer responsible for the object.
|
||||||
@@ -30,9 +32,8 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
|||||||
:type relating_actor: ifcopenshell.entity_instance
|
:type relating_actor: ifcopenshell.entity_instance
|
||||||
:param related_object: The object the actor is responsible for.
|
:param related_object: The object the actor is responsible for.
|
||||||
:type related_object: ifcopenshell.entity_instance
|
:type related_object: ifcopenshell.entity_instance
|
||||||
:return: The updated IfcRelAssignsToActor relationship or none if there
|
:return: None
|
||||||
is no more valid relationship.
|
:rtype: None
|
||||||
:rtype: None, ifcopenshell.entity_instance
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -72,4 +73,3 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
|||||||
related_objects.remove(settings["related_object"])
|
related_objects.remove(settings["related_object"])
|
||||||
rel.RelatedObjects = related_objects
|
rel.RelatedObjects = related_objects
|
||||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||||
return rel
|
|
||||||
|
|||||||
@@ -17,9 +17,12 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def add_arbitrary_profile(file, profile=None, name=None) -> None:
|
def add_arbitrary_profile(
|
||||||
|
file: ifcopenshell.file, profile: list[tuple[float, float]], name: Optional[str] = None
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new arbitrary polyline-based profile
|
"""Adds a new arbitrary polyline-based profile
|
||||||
|
|
||||||
The profile is represented as a polyline defined by a list of
|
The profile is represented as a polyline defined by a list of
|
||||||
@@ -30,7 +33,7 @@ def add_arbitrary_profile(file, profile=None, name=None) -> None:
|
|||||||
identical.
|
identical.
|
||||||
|
|
||||||
:param profile: A list of coordinates
|
:param profile: A list of coordinates
|
||||||
:type profile: list[list[float]]
|
:type profile: list[tuple[float, float]]
|
||||||
:param name: If the profile is semantically significant (i.e. to be
|
:param name: If the profile is semantically significant (i.e. to be
|
||||||
managed and reused by the user) then it must be named. Otherwise,
|
managed and reused by the user) then it must be named. Otherwise,
|
||||||
this may be left as none.
|
this may be left as none.
|
||||||
|
|||||||
+9
-3
@@ -17,9 +17,15 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def add_arbitrary_profile_with_voids(file, outer_profile=None, inner_profiles=None, name=None) -> None:
|
def add_arbitrary_profile_with_voids(
|
||||||
|
file: ifcopenshell.file,
|
||||||
|
outer_profile: list[tuple[float, float]],
|
||||||
|
inner_profiles: list[list[tuple[float, float]]],
|
||||||
|
name: Optional[str] = None,
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new arbitrary polyline-based profile with voids
|
"""Adds a new arbitrary polyline-based profile with voids
|
||||||
|
|
||||||
The outer profile is represented as a polyline defined by a list of
|
The outer profile is represented as a polyline defined by a list of
|
||||||
@@ -35,9 +41,9 @@ def add_arbitrary_profile_with_voids(file, outer_profile=None, inner_profiles=No
|
|||||||
provided in SI meters.
|
provided in SI meters.
|
||||||
|
|
||||||
:param outer_profile: A list of coordinates
|
:param outer_profile: A list of coordinates
|
||||||
:type profile: list[float]
|
:type profile: list[tuple[float, float]]
|
||||||
:param inner_profiles: A list of polylines
|
:param inner_profiles: A list of polylines
|
||||||
:type profile: list[list[float]]
|
:type profile: list[list[tuple[float, float]]]
|
||||||
:param name: If the profile is semantically significant (i.e. to be
|
:param name: If the profile is semantically significant (i.e. to be
|
||||||
managed and reused by the user) then it must be named. Otherwise,
|
managed and reused by the user) then it must be named. Otherwise,
|
||||||
this may be left as none.
|
this may be left as none.
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
def add_parameterized_profile(file, ifc_class=None) -> None:
|
def add_parameterized_profile(file: ifcopenshell.file, ifc_class: str) -> ifcopenshell.entity_instance:
|
||||||
"""Adds a new parameterised profile
|
"""Adds a new parameterised profile
|
||||||
|
|
||||||
IFC offers parameterised profiles for common standardised hot roll
|
IFC offers parameterised profiles for common standardised hot roll
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import ifcopenshell
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def edit_profile(file, profile=None, attributes=None) -> None:
|
def edit_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||||
"""Edits the attributes of an IfcProfileDef
|
"""Edits the attributes of an IfcProfileDef
|
||||||
|
|
||||||
For more information about the attributes and data types of an
|
For more information about the attributes and data types of an
|
||||||
@@ -26,7 +28,7 @@ def edit_profile(file, profile=None, attributes=None) -> None:
|
|||||||
:param profile: The IfcProfileDef entity you want to edit
|
:param profile: The IfcProfileDef entity you want to edit
|
||||||
:type profile: ifcopenshell.entity_instance
|
:type profile: ifcopenshell.entity_instance
|
||||||
:param attributes: a dictionary of attribute names and values.
|
:param attributes: a dictionary of attribute names and values.
|
||||||
:type attributes: dict, optional
|
:type attributes: dict
|
||||||
:return: None
|
:return: None
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ def edit_profile(file, profile=None, attributes=None) -> None:
|
|||||||
ifcopenshell.api.run("profile.edit_profile", model,
|
ifcopenshell.api.run("profile.edit_profile", model,
|
||||||
profile=circle, attributes={"ProfileName": "1000mm Dia"})
|
profile=circle, attributes={"ProfileName": "1000mm Dia"})
|
||||||
"""
|
"""
|
||||||
settings = {"profile": profile, "attributes": attributes or {}}
|
settings = {"profile": profile, "attributes": attributes}
|
||||||
|
|
||||||
for name, value in settings["attributes"].items():
|
for name, value in settings["attributes"].items():
|
||||||
setattr(settings["profile"], name, value)
|
setattr(settings["profile"], name, value)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def remove_profile(file, profile=None) -> None:
|
def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance) -> None:
|
||||||
"""Removes a profile
|
"""Removes a profile
|
||||||
|
|
||||||
:param profile: The IfcProfileDef to remove.
|
:param profile: The IfcProfileDef to remove.
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.api.owner.settings
|
import ifcopenshell.api.owner.settings
|
||||||
from typing import Optional
|
import ifcopenshell.util.element
|
||||||
|
from typing import Optional, Any, Union
|
||||||
|
|
||||||
|
|
||||||
def append_asset(
|
def append_asset(
|
||||||
@@ -124,6 +125,9 @@ def append_asset(
|
|||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
|
file: ifcopenshell.file
|
||||||
|
settings: dict[str, Any]
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
# mapping of old element ids to new elements
|
# mapping of old element ids to new elements
|
||||||
self.added_elements: dict[int, ifcopenshell.entity_instance] = {}
|
self.added_elements: dict[int, ifcopenshell.entity_instance] = {}
|
||||||
@@ -223,7 +227,7 @@ class Usecase:
|
|||||||
|
|
||||||
return element
|
return element
|
||||||
|
|
||||||
def add_element(self, element):
|
def add_element(self, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
if element.id() == 0:
|
if element.id() == 0:
|
||||||
return
|
return
|
||||||
existing_element = self.get_existing_element(element)
|
existing_element = self.get_existing_element(element)
|
||||||
@@ -262,7 +266,7 @@ class Usecase:
|
|||||||
elif value:
|
elif value:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_inverses(self, element):
|
def check_inverses(self, element: ifcopenshell.entity_instance) -> None:
|
||||||
for source_class, attributes in self.whitelisted_inverse_attributes.items():
|
for source_class, attributes in self.whitelisted_inverse_attributes.items():
|
||||||
if not element.is_a(source_class):
|
if not element.is_a(source_class):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from re import findall
|
from re import findall
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
from typing import Literal, Union, Any
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import isodate
|
import isodate
|
||||||
@@ -104,7 +105,18 @@ def readable_ifc_duration(string):
|
|||||||
return final_string
|
return final_string
|
||||||
|
|
||||||
|
|
||||||
def datetime2ifc(dt, ifc_type):
|
def datetime2ifc(
|
||||||
|
dt: Union[datetime.date, str],
|
||||||
|
ifc_type: Literal[
|
||||||
|
"IfcDuration",
|
||||||
|
"IfcTimeStamp",
|
||||||
|
"IfcDateTime",
|
||||||
|
"IfcDate",
|
||||||
|
"IfcTime",
|
||||||
|
"IfcCalendarDate",
|
||||||
|
"IfcLocalTime",
|
||||||
|
],
|
||||||
|
) -> Union[int, str, dict[str, Any]]:
|
||||||
if isinstance(dt, str):
|
if isinstance(dt, str):
|
||||||
if ifc_type == "IfcDuration":
|
if ifc_type == "IfcDuration":
|
||||||
return dt
|
return dt
|
||||||
@@ -145,6 +157,7 @@ def datetime2ifc(dt, ifc_type):
|
|||||||
"MinuteComponent": dt.minute,
|
"MinuteComponent": dt.minute,
|
||||||
"SecondComponent": dt.second,
|
"SecondComponent": dt.second,
|
||||||
}
|
}
|
||||||
|
raise TypeError(f"Unsupported ifc_type for conversion from datetime.datetime = {ifc_type}.")
|
||||||
|
|
||||||
|
|
||||||
def string_to_date(string):
|
def string_to_date(string):
|
||||||
|
|||||||
Reference in New Issue
Block a user