ifcopenshell.api.system.assign_port#

Module Contents#

class ifcopenshell.api.system.assign_port.Usecase(file, element=None, port=None)#

Assigns a port to an element

If you have an orphaned port, you may assign it to a distribution element using this function. Ports should typically not be orphaned, but it may be useful when patching up models.

Parameters
Returns

The IfcRelNests relationship, or the IfcRelConnectsPortToElement for IFC2X3.

Return type

ifcopenshell.entity_instance.entity_instance

Example:

# Create a duct
duct = ifcopenshell.api.run("root.create_entity", model,
    ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")

# Create 2 ports, one for either end.
port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
port2 = ifcopenshell.api.run("system.add_port", model, element=duct)

# Unassign one port for some weird reason.
ifcopenshell.api.run("system.unassign_port", model, element=duct, port=port1)

# Reassign it back
ifcopenshell.api.run("system.assign_port", model, element=duct, port=port1)
execute(self)#
execute_ifc2x3(self)#
update_port_placement(self)#