Jump to content
Developer Wiki and Function Reference Links ×

How to check Angle (direction) of Dimension


Recommended Posts

Dimension Direction.vwx

I am able to check if a Dimension is vertical or horizontal with 

direction = vs.GetObjectVariableReal(dim,value)

On my mac version, it returns 0 for horizontal and 1.0 or -1.0 for vertical Dimensions. Unfortunately this seems not to work on Windows. There is always 0.0.
I could test if xDiff is bigger than yDiff (of the Dimension Points) an decide it is horizontal but this can result in errors with some dimensions.

Anyone has an Idea to get that information reliable?


Edited by DomC
Link to comment

Hi Dom,


Try this:

Procedure T;
    h1 : HANDLE;
    b1, b2, b3 : BOOLEAN;
    i1 : INTEGER;
    r1, rAngle : REAL;
    h1 := FIn3D(FSActLayer);
        IF (GetType(h1) = 2) THEN BEGIN 
            GetMarker(h1, b2, b3, i1, r1);
            IF b2 | b3 THEN BEGIN
                b1 := True;
                rAngle := HAngle(h1);
        h1 := NextObj(h1);
    UNTIL (h1 = Nil) | b1; 
    Message('Angle is: ', rAngle);

Link to comment

Even better as a function:


Function GetDimAngle(h1 : HANDLE) : REAL;
    h2 : HANDLE;
    i1 : INTEGER;
    r1 : REAL;
    b1, b2, b3 : BOOLEAN;
    h2 := FIn3D(h1);
        IF (GetType(h2) = 2) THEN BEGIN 
            GetMarker(h2, b2, b3, i1, r1);
            IF b2 | b3 THEN BEGIN
                b1 := True;
                GetDimAngle := HAngle(h2);
        h2 := NextObj(h2);
    UNTIL (h2 = Nil) | b1;

  • Like 2
Link to comment

Fantastic Julian this is a very reliable solution, Thank you. I implemented this way:

dim = vs.FSActLayer()

def GetDimAngle(h1):
    h2 = vs.FIn3D(h1)
    DimAngle = 0
    while h2 != vs.Handle(0):
        if vs.GetTypeN(h2) == 2:
            BOOLEAN, style, angle, size, width, thicknessBasis, thickness, visibility = vs.GetObjBeginningMarker(h2)
            if style:
                DimAngle =  round(vs.HAngle(h2),0)
        h2 = vs.NextObj(h2)
    return DimAngle 

DimAngle = GetDimAngle(dim)


  • Like 1
Link to comment
  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...