Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Designer Class / PlaceRibbonCable Method / PlaceRibbonCable(LibRibbonCable,IOccRibbonPin,IOccRibbonPin,List<PlacePosition>,List<Connection>,ApiLinkType) Method
Library part of placed cable.
First end of the cable will be connected to this pin.
Second end of the cable will be connected to this pin.
A list of positions, where control points of placed cable will be created.
Connections of wires of placed cable. Determines which pins on connectors will be connected by a wire.
Determines if part's accessories will be placed with part. Mandatory, Optional, both types or None accessories can be placed. This enum has the Flags attribute.
Example
In This Topic
    PlaceRibbonCable(LibRibbonCable,IOccRibbonPin,IOccRibbonPin,List<PlacePosition>,List<Connection>,ApiLinkType) Method
    In This Topic
    Places a ribbon cable from library to designer.
    Syntax

    Parameters

    libRibbonCable
    Library part of placed cable.
    ribbonPin1
    First end of the cable will be connected to this pin.
    ribbonPin2
    Second end of the cable will be connected to this pin.
    ribbonCableControlPoints
    A list of positions, where control points of placed cable will be created.
    connections
    Connections of wires of placed cable. Determines which pins on connectors will be connected by a wire.
    linkType
    Determines if part's accessories will be placed with part. Mandatory, Optional, both types or None accessories can be placed. This enum has the Flags attribute.

    Return Value

    Placed cable.
    Exceptions
    ExceptionDescription
    This file is not opened.
    Api is not in an initialized state. You can get current state from EPLAN.Harness.API.HpdApi.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.HpdApi.Init method. If API is in failed state, you can not resurrect it.
    The object is in invalid state. Obtain a new one.
    Thrown when the occurrence is not part of this document.
    Remarks
    Example
    This simple example shows how to place two connectors to workspace and connect them with a ribbon cable.
    // obtain a list of positions of control points in an arbitrary way, first two positions are used for connector positions, the rest for cable's control points
    List<TransformProperty<LengthProperty>> controlPointPositions = ...;
    
    // Initialization of api and documents.
    HpdApi api = HpdApi.GetInstance();
    api.Init();
    					
    Project proj = api.OpenProject($"{pathToMyProject}");
    Variant variant = proj.GetVariants().First();
    Workspace workspace = variant.GetWorkspaces().First();
    workspace.Open(false, false);
    
    // Fetching library parts of connectors and ribbon cable
    BaseLibCable ribbonCableLib = (BaseLibCable)proj.ActiveConnection.GetLibraryPartsByPartNumber($"{ribbonCableLibPartNumber}").FirstOrDefault();
    BaseLibConnector ribbonConnector = (BaseLibConnector)proj.ActiveConnection.GetLibraryPartsByPartNumber($"{ribbonConnectorLibPartNumber}").FirstOrDefault();
    
    var zeroRotation = new TransformProperty<AngleProperty>(new AngleProperty(0, Unit.Degree), new AngleProperty(0, Unit.Degree), new AngleProperty(0, Unit.Degree));
    
    // Place connectors (assume they have a ribbon super pin)
    IConnectableObjectBase conn1 = workspace.PlaceConnectableObject(ribbonConnector, controlPointPositions[0], zeroRotation);
    IConnectableObjectBase conn2 = workspace.PlaceConnectableObject(ribbonConnector, controlPointPositions[1], zeroRotation);
    
    // Get ribbon pins from connectors
    IOccRibbonPin pin1 = conn1.Children.FirstOrDefault(ch => ch is IOccRibbonPin) as IOccRibbonPin;
    IOccRibbonPin pin2 = conn2.Children.FirstOrDefault(ch => ch is IOccRibbonPin) as IOccRibbonPin;
    
    // Place ribbon cable with mandatory accessories.
    IOccRibbonCable cable = workspace.PlaceRibbonCable(ribbonCableLib as LibRibbonCable, pin1, pin2, controlPointPositions.Skip(2).ToList(), new List<Connection>(), ApiLinkType.Mandatory);
    
    // Save documents
    workspace.Save();
    workspace.Close();
    proj.Save();
    proj.Close();
    api.Close();
    See Also