This commit is contained in:
Andrej730
2024-05-10 11:21:53 +05:00
parent e7eb00eaa3
commit c50d1ea2fe
105 changed files with 502 additions and 251 deletions
@@ -18,9 +18,10 @@
import ifcopenshell
import ifcopenshell.api
from typing import Optional
def add_port(file, element=None) -> None:
def add_port(file: ifcopenshell.file, element: Optional[ifcopenshell.entity_instance] = None) -> None:
"""Adds a new distribution port to an element
A distribution port represents a connection point on an element, where
@@ -34,7 +35,7 @@ def add_port(file, element=None) -> None:
:param element: The IfcDistributionElement you want to add a
distribution port to.
:type element: ifcopenshell.entity_instance
:type element: ifcopenshell.entity_instance, optional
:return: The newly created IfcDistributionPort
:rtype: ifcopenshell.entity_instance
@@ -19,9 +19,14 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.guid
from typing import Union
def assign_flow_control(file, relating_flow_element=None, related_flow_control=None) -> None:
def assign_flow_control(
file: ifcopenshell.file,
relating_flow_element: ifcopenshell.entity_instance,
related_flow_control: ifcopenshell.entity_instance,
) -> Union[ifcopenshell.entity_instance, None]:
"""Assigns to the flow element control element that either sense or control
some aspect of the flow element.
@@ -22,7 +22,9 @@ import ifcopenshell.guid
import ifcopenshell.util.placement
def assign_port(file, element=None, port=None) -> None:
def assign_port(
file: ifcopenshell.file, element: ifcopenshell.entity_instance, port: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
"""Assigns a port to an element
If you have an orphaned port, you may assign it to a distribution
@@ -73,7 +75,7 @@ class Usecase:
for rel in rels:
if self.settings["port"] in rel.RelatedObjects:
return
return rel
if rels:
rel = rels[0]
@@ -97,7 +99,7 @@ class Usecase:
def execute_ifc2x3(self):
for rel in self.settings["element"].HasPorts or []:
if rel.RelatingPort == self.settings["port"]:
return
return rel
rel = self.file.create_entity(
"IfcRelConnectsPortToElement",
GlobalId=ifcopenshell.guid.new(),
@@ -20,9 +20,16 @@ import ifcopenshell
import ifcopenshell.api
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Optional
def connect_port(file, port1=None, port2=None, direction="NOTDEFINED", element=None) -> None:
def connect_port(
file: ifcopenshell.file,
port1: ifcopenshell.entity_instance,
port2: ifcopenshell.entity_instance,
direction: str = "NOTDEFINED",
element: Optional[ifcopenshell.entity_instance] = None,
) -> None:
"""Connects two ports together
A distribution element (e.g. a duct) may be connected to another
@@ -61,7 +68,7 @@ def connect_port(file, port1=None, port2=None, direction="NOTDEFINED", element=N
connectivity is made, such as a segment or fitting. This is only to
be used for implicit port connectivity where the segments and
fittings are less important.
:type element: ifcopenshell.entity_instance
:type element: ifcopenshell.entity_instance, optional
Example:
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def disconnect_port(file, port=None) -> None:
def disconnect_port(file: ifcopenshell.file, port: ifcopenshell.entity_instance) -> None:
"""Disconnects a port from any other port
A port may only be connected to one other port, so the other port 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_system(file, system=None, attributes=None) -> None:
def edit_system(file: ifcopenshell.file, system: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcSystem
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_system(file, system=None, attributes=None) -> None:
:param system: The IfcSystem entity you want to edit
:type system: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_system(file, system=None) -> None:
def remove_system(file: ifcopenshell.file, system: ifcopenshell.entity_instance) -> None:
"""Removes a distribution system
All the distribution elements within the system are retained.
@@ -21,7 +21,11 @@ import ifcopenshell.api
import ifcopenshell.util.element
def unassign_flow_control(file, relating_flow_element=None, related_flow_control=None) -> None:
def unassign_flow_control(
file: ifcopenshell.file,
relating_flow_element: ifcopenshell.entity_instance,
related_flow_control: ifcopenshell.entity_instance,
) -> None:
"""Unassigns flow control element from the flow element.
:param related_flow_control: IfcDistributionControlElement controling the
@@ -29,9 +33,8 @@ def unassign_flow_control(file, relating_flow_element=None, related_flow_control
:type related_flow_control: ifcopenshell.entity_instance
:param relating_flow_element: The IfcDistributionFlowElement that is being controlled
:type relating_flow_element: ifcopenshell.entity_instance
:return: If the control still is related to other objects, the
IfcRelFlowControlElements is returned, otherwise None.
:rtype: ifcopenshell.entity_instance, None
:return: None
:rtype: None
Example:
@@ -71,4 +74,3 @@ def unassign_flow_control(file, relating_flow_element=None, related_flow_control
related_flow_controls.remove(settings["related_flow_control"])
assignment.RelatedControlElements = related_flow_controls
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": assignment})
return assignment
@@ -18,9 +18,12 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
def unassign_port(file, element=None, port=None) -> None:
def unassign_port(
file: ifcopenshell.file, element: ifcopenshell.entity_instance, port: ifcopenshell.entity_instance
) -> None:
"""Unassigns a port to an element
Ports are typically always assigned to a distribution element, but in