ifcopenshell.api.system.assign_port

Module Contents

class ifcopenshell.api.system.assign_port.Usecase
execute()
execute_ifc2x3()
update_port_placement()
ifcopenshell.api.system.assign_port.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 element using this function. Ports should typically not be orphaned, but it may be useful when patching up models.

Parameters:
  • element (ifcopenshell.entity_instance) – The IfcDistributionElement to assign the port to.

  • port (ifcopenshell.entity_instance) – The IfcDistributionPort you want to assign.

Returns:

The IfcRelNests relationship, or the IfcRelConnectsPortToElement for IFC2X3.

Return type:

ifcopenshell.entity_instance

Example:

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

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

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

# Reassign it back
ifcopenshell.api.system.assign_port(model, element=duct, port=port1)