Jump to content

How to check Angle (direction) of Dimension


DomC

Recommended Posts

Dimension Direction.vwx

Hello
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?

image.png.0e9b719b450b69c989bfe32eba866f50.png

Edited by DomC
Link to comment

Hi Dom,

 

Try this:


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

Link to comment

Even better as a function:

 

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

  • Like 1
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)
vs.AlrtDialog(str(DimAngle))

 

Link to comment

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.

Guest
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...