Results 1 to 10 of 10

Thread: Angle of leader segment

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Talking Angle of leader segment

    Hi all-

    I am trying to find a way that I can select a segment of a leader and have it return that segment's angle. I have tried several approaches with very little success. Any help is greatly appreciated. Thanks in advance.

    Manuel A. Ayala

  2. #2
    Active Member
    Join Date
    2008-06
    Posts
    52
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    If I do something like this

    (entget (car (entsel)))

    then I can see the objects data values. From there look for "LEADER LINE" and group codes 10. this is the coordinates for the starting end points for the leader. If I use any two I can calculate the angle in between.

    For reference I am attaching the data that was returned by the "entget" function.

    Hope this helps
    Attached Files Attached Files

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    I'd advise getting something like (setq en (entsel)), the 2nd portion of this would be the cursor position of the selection. So then you check the leader's vectors, first get the leader's data: (setq ed (entget (car en))) from the 1st portion = ename.
    Then extract the portion starting with the vectors: (setq vectors (member (assoc 10 ed) ed))
    Now step through each, compare the distances from the selection point to perpendicular of each vector. The smallest distance shows which vector was picked.
    Last edited by irneb; 2009-02-09 at 10:07 AM. Reason: Some typo's fixed

  4. #4
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    Quote Originally Posted by cadconcepts View Post
    Hi all-

    I am trying to find a way that I can select a segment of a leader and have it return that segment's angle. I have tried several approaches with very little success. Any help is greatly appreciated. Thanks in advance.

    Manuel A. Ayala

    Try this:
    Code:
    (defun LeaderAngleAtPoint( / ent obj pt param slope)
      (setq
        ent (entsel)
        obj (vlax-ename->vla-object (car ent))
        pt (cadr ent)
        param (vlax-curve-getparamatpoint obj (trans  (osnap pt "near")(car ent) 0))
        slope(vlax-curve-getFirstDeriv obj param)
        )
      (angle '(0 0 0) slope)
      )
    Note that this will work with:
    Lines
    Plines
    Arcs
    Circles
    Splines and
    Leaders

  5. #5
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Wink Re: Angle of leader segment

    Mweaver

    Thank you very much for the code. I will try it out.

    Manuel

  6. #6
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    Quote Originally Posted by cadconcepts View Post
    Mweaver

    Thank you very much for the code. I will try it out.

    Manuel
    You are welcome,
    Mike

  7. #7
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Smile Re: Angle of leader segment

    mweaver

    Is it possible, using similar code, to find the angle of line or polyline within a block as well? Thanks again.

    Manuel

  8. #8
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    Quote Originally Posted by cadconcepts View Post
    mweaver

    Is it possible, using similar code, to find the angle of line or polyline within a block as well? Thanks again.

    Manuel
    With the help of some procedures found here(http://www.theswamp.org/index.php?topic=26591.0 Reply #14 has a link to a file: objmatrix v2.lsp) The following code will get the slope of a nested line:
    Code:
    (defun GetAngleOfNestedLine( / )
      (setq
        ent (nentsel)
        elist (entget (car ent))
        p0 (transpt (cdr (assoc 10 elist)) (last ent) 2 1)
        p1 (transpt (cdr (assoc 11 elist)) (last ent) 2 1)
        ang (angle p0 p1)
        )
      )
    Doing the same with a pline is a bit tougher.

  9. #9
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    mweaver

    Thanks again.

    Manuel

  10. #10
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Angle of leader segment

    I had a brainstorm (and remembered a technique pioneered by Robert Grandmaison). Here is a rough routine that should work on all the objects mentioned in my earlier post, even if they're nested.
    Code:
    (defun c:test( / ent e ent2 p0 obj p1 param1 slope)
      (vl-load-com)
      (command "undo" "be")
      (setq
        ent (nentsel)
        )
        (foreach e (last ent)
          (command "explode" e "")
          )
      (setq
        ent2 (nentselp (cadr ent))
        p0 (osnap (cadr ent2) "Near")
        obj (vlax-ename->vla-object (car ent2))
        p1 (vlax-curve-getClosestPointTo obj p0)
        param1 (vlax-curve-getParamAtPoint obj p1)
        slope (vlax-curve-getfirstderiv obj param1)
        )
      (command "undo" "back")
      (angle '(0 0 0) slope)
      )
    This is a proof of concept only, with very little testing. It needs to have error checking added as well as testing for and dealing with blocks set to not allow exploding (toggle that property, explode the block, and toggle the property back).

    Hopefully this will get you headed in the right direction.

    Mike

Similar Threads

  1. 2013 Can't change angle of leader notes
    By rmwandbandit671917 in forum AutoCAD Mechanical - General
    Replies: 1
    Last Post: 2014-06-02, 07:44 PM
  2. Dim angle in Leader
    By fredacx363311 in forum AutoLISP
    Replies: 4
    Last Post: 2013-03-05, 04:38 PM
  3. 2012: AUTOCAD CIVIL 3D 2012 MULTI LEADER TEXT ANGLE
    By ryager in forum AutoCAD Annotation
    Replies: 0
    Last Post: 2012-04-25, 04:10 PM
  4. Split section and angle one segment
    By BMcCallum in forum Revit Architecture - General
    Replies: 1
    Last Post: 2007-01-01, 05:41 PM
  5. length of first leader line segment
    By Maverick91 in forum AutoCAD General
    Replies: 3
    Last Post: 2006-02-01, 01:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •