Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Drawing2D Class / CreateRectangle Method
First point of rectangle's bottom line. (Point A in common notation)
Second point of rectangle's bottom line. (Point B in common notation)
Height point of rectangle - determines the top line of the rectangle
Example
In This Topic
    CreateRectangle Method
    In This Topic
    Creates a rectangle based on specified points.
    Syntax

    Parameters

    point1
    First point of rectangle's bottom line. (Point A in common notation)
    point2
    Second point of rectangle's bottom line. (Point B in common notation)
    point3
    Height point of rectangle - determines the top line of the rectangle

    Return Value

    Created occurrence.
    Exceptions
    ExceptionDescription
    The object is in invalid state. Obtain a new one.

    Internal error of HpD or HpD API.

    IMPORTANT: Throwing this exception changes HpD Api's state to Failed.

    Argument is invalid. The exception is thrown when a wrong argument is passed to the method or the setter of property.
    Argument is null.
    Remarks
    The top line is defined by the height point - the point C is the projection of Height point (parameter point3) to a line perpendicular to line AB. To create a rectangle which is rotated by nonzero angle with respect to coordinate axes, it might be easier to create a non rotated rectangle first and then rotate it by setting rotation.
    Example
    Following code creates a square with points (0;0), (0;1), (1;0), (1;1), where the lengths are in millimeters in this case
    var api = HpdApi.GetInstance();
    api.Init();
    					
    var project = api.OpenProject(...);
    var cd = project.GetVariants().FirstOrDefault().GetCableDrawings().FirstOrDefault(n => n.Name == ...);
    cd.Open(false, false);
    
    var pos0 = new Transform2DProperty<LengthProperty>(new LengthProperty(0, Unit.Millimeter), new LengthProperty(0, Unit.Millimeter));
    var pos1 = new Transform2DProperty<LengthProperty>(new LengthProperty(1, Unit.Millimeter), new LengthProperty(0, Unit.Millimeter));
    var pos2 = new Transform2DProperty<LengthProperty>(new LengthProperty(0, Unit.Millimeter), new LengthProperty(1, Unit.Millimeter));
    var rect = cd.CreateRectangle(pos0, pos1, pos2);
    					
    cd.Save();
    cd.Close();
    project.Close();
    See Also