mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
typing
This commit is contained in:
@@ -15,9 +15,12 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
A layer represents a portion of material within a layered build up,
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
drawing or schedule.
|
||||
:type name: str
|
||||
:type name: str, optional
|
||||
:param category: The category of the material.
|
||||
:type category: str, optional
|
||||
:return: The newly created IfcMaterial
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# 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
|
||||
|
||||
IFC allows you to state that objects are made out of multiple materials.
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
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
|
||||
|
||||
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:
|
||||
def execute(self):
|
||||
file: ifcopenshell.file
|
||||
def execute(self) -> None:
|
||||
# TODO: handle composite profiles
|
||||
old_profile = self.settings["material_profile"].Profile
|
||||
self.settings["material_profile"].Profile = self.settings["profile"]
|
||||
@@ -117,7 +120,7 @@ class Usecase:
|
||||
# TODO: check remove deep
|
||||
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")
|
||||
if not representation:
|
||||
return
|
||||
|
||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
||||
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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
:type element: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: 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,
|
||||
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():
|
||||
setattr(settings["element"], name, value)
|
||||
|
||||
@@ -15,9 +15,16 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
:type usage: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: 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,
|
||||
usage=rel.RelatingMaterial, attributes={"OffsetFromReferenceLine": 200})
|
||||
"""
|
||||
settings = {"usage": usage, "attributes": attributes or {}}
|
||||
settings = {"usage": usage, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["usage"], name, value)
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# 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"""
|
||||
|
||||
settings = {"material": material, "attributes": attributes or {}}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["material"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(material, name, value)
|
||||
|
||||
@@ -17,7 +17,17 @@
|
||||
# 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
|
||||
|
||||
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
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.geom
|
||||
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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
Note that it is invalid to have zero items in a set, so you should leave
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
def remove_material(file, material=None) -> None:
|
||||
def remove_material(file: ifcopenshell.file, material: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a material
|
||||
|
||||
If the material is used in a material set, the corresponding layer,
|
||||
|
||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
||||
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
|
||||
|
||||
All set items, such as layers, profiles, or constituents will also be
|
||||
|
||||
@@ -21,7 +21,7 @@ import ifcopenshell
|
||||
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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
In some material sets, the order have meaning, like in a layer set. In
|
||||
|
||||
Reference in New Issue
Block a user