Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Designer Class / PlaceAssembly Method
The part which is placed.
Position of the part in the workspace/workdesk.
Rotation of the part in the workspace/workdesk.
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. Default is mandatory accessories.
Example
In This Topic
    PlaceAssembly Method
    In This Topic
    Place a Assembly or Device on position.
    Syntax

    Parameters

    part
    The part which is placed.
    transform
    Position of the part in the workspace/workdesk.
    rotation
    Rotation of the part in the workspace/workdesk.
    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. Default is mandatory accessories.

    Return Value

    Placed occurrence.
    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 type of part can not be placed by the method.
    Thrown when placing this part failed.
    Remarks

    When linked type is not set no accessories of the part will be placed.

    Example
    This example shows how to place an Assembly to workspace.
    /// Obtain workspace beforehand and open for writing.
    Workspace workspace = ...
    workspace.Open(false, false);
    
    // Obtain a part from active library.
    IEnumerable<BaseLibraryPart>parts = project.ActiveConnection.GetLibraryPartsByPartNumber("part1");
    BaseLibraryPart part = parts.FirstOrDefault();
    
    // Prepare position and rotation.
    TransformProperty<LengthProperty> position = new TransformProperty<LengthProperty>(new LengthProperty(1, Unit.Meter), new LengthProperty(0, Unit.Meter), new LengthProperty(0, Unit.Meter));
    TransformProperty<AngleProperty> rotation = new TransformProperty<AngleProperty>(new AngleProperty(0, Unit.Degree), new AngleProperty(0, Unit.Degree), new AngleProperty(0, Unit.Degree));
    
    // Place a Assembly with mandatory and optional accessories.
    workspace.PlaceAssembly(part as BaseLibAssembly, position, rotation , ApiLinkType.Optional | ApiLinkType.Mandatory);
    
    // Or place a Assembly without accessories.
    workspace.PlaceAssembly(part as BaseLibAssembly, position, rotation);
    See Also