Results 1 to 5 of 5

Thread: Change Multileader angle

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

    Default Change Multileader angle

    Hi All
    I am trying to alter the following code so that I can specify an angle that would be applied to all selected multileaders. Ideally, I want change the angle between point 1 and point two without changing the initial point. Also, I want the text to remain in its horizontal location. As it stands now, the routine is not moving the initial point but it is moving the text vertically. Any help is greatly appreciated.
    Manuel



    Code:
    (defun c:mldrang (/ _angle _mlangle mleader_sset index line1 angle_negativity line1_point2)
       (if (setq _mlangle (getangle "\nStart angle for leader or zero for none: "))
         (progn
           (setq _angle (read (angtos _mlangle)))
           (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
           (if (not (zerop _angle)) (setq angle_negativity (/ _angle (abs _angle))))
           (if (< 360 (abs _angle))
             (* angle_negativity (setq _angle (- (abs _angle) (* (fix (/ (abs _angle) 360)) 360))))
           )
           (if (minusp _angle)
             (setq _angle (/ (* (- 360 (abs _angle)) pi) 180))
             (setq _angle (/ (* _angle pi) 180))
           )
           (if (setq mleader_sset (ssget '((0 . "multileader"))))
             (repeat (setq index (sslength mleader_sset))
               (setq line1 (vlax-invoke (setq mleader_object (vlax-ename->vla-object (ssname mleader_sset (setq index (1- index))))) 'getleaderlinevertices 0)
                     line1_point2 (polar (list (nth 0 line1) (nth 1 line1))
                     _angle (distance (list (nth 0 line1) (nth 1 line1)) (list (nth 3 line1) (nth 4 line1))))
               ) 
               (vlax-invoke mleader_object 'setleaderlinevertices 0 (list (nth 0 line1) (nth 1 line1) (nth 2 line1) (car line1_point2) (cadr line1_point2) (nth 2 line1)))
               (if (< (car line1_point2) (car line1))
                 (vlax-invoke mleader_object 'setdoglegdirection 0 (list -1.0 0.0 0.0))
                 (vlax-invoke mleader_object 'setdoglegdirection 0 (list +1.0 0.0 0.0))
               )
               (vlax-invoke mleader_object 'setleaderlinevertices 0 (list (nth 0 line1) (nth 1 line1) (nth 2 line1) (car line1_point2) (cadr line1_point2) (nth 2 line1)))
               (princ (strcat "\rMLeaders remain to process: " (itoa index)))
             )
           )
         )
       )
    (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
    (princ)
    )

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,102
    Login to Give a bone
    0

    Default Re: Change Multileader angle

    Can you attach a screen shot showing before and after the desired outcome?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

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

    Default Re: Change Multileader angle

    Oopie
    Here's a screen shot of the issue I am trying to resolve. I want Pt1 to remain fixed and text can move if need be horizontally. The length between Pt2 and PT3 can adjust as necessary as well. Thanks.
    Manuel
    Attached Images Attached Images

  4. #4
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Change Multileader angle

    This is one way to solve this

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard copyright 2023 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Any use by unauthorized person or business is strictly prohibited.
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;* C:MLAN
    ;* Command Line function to change angle of mleader
    
    ;* C:MLeaderAngle
    ;* Command Line function to change angle of mleader
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List 
    ;___________________________________________________________________________________________________________|
    
    ;* (ListParse lstCoordinates intNumber)
    ;* Function to parse a list of coordinates into a list of sublists of length intNumber
    
    ;$ End Header
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line function to change angle of mleader
    ;___________________________________________________________________________________________________________|
    
    (defun C:MLAN ()(C:MLeaderAngle))
    
    (defun C:MLeaderAngle (/ entSelection
                             lstCoordinates
                             lstPoints
                             lstPoint0
                             lstPoint1
                             lstPoint2
                             lstPoint3
                             objSelection
                             sngRadians
                             sngRise
                             sngRun
                          )
     (if (and (princ "\nSelect MLeader: ")
              (setq ssSelection    (ssget ":S:E" (list (cons 0 "MULTILEADER"))))
              (setq entSelection   (ssname ssSelection 0))
              (setq objSelection   (vlax-ename->vla-object entSelection))
              (setq lstCoordinates (vlax-invoke objSelection "GetLeaderLineVertices" 0))
              (setq lstPoints      (listparse lstCoordinates 3))
              (setq lstPoint0      (nth 0 lstPoints))
              (setq lstPoint1      (nth 1 lstPoints))
              (setq lstPoint2      (getpoint lstPoint0 "\nSelect New Angle: "))
              (setq sngRadians     (angle lstPoint0 lstPoint2))
              (setq sngRise        (- (cadr lstPoint1) (cadr lstPoint0)))
              (/= sngRise 0.0)
              (> (abs sngRise) 0.1)
              (setq sngRun         (/ sngRise (tan sngRadians)))
              (setq lstPoint3      (mapcar '+ lstPoint0 (list sngRun sngRise 0.0)))
              (setq lstCoordinates (append lstPoint0 lstPoint3))
         )
      (progn (vlax-invoke objSelection "SetLeaderLineVertices" 0 lstCoordinates) T)
     )
    )
    
    
    ;___________________________________________________________________________________________________________
    ;
    ; Function to parse a list of coordinates into a list of sublists of length intNumber
    ;___________________________________________________________________________________________________________
    
    (defun ListParse (lstCoordinates intNumber / lstPoint lstPoints)
     (repeat (fix (/ (length lstCoordinates) intNumber))
      (setq lstPoint nil)
      (repeat intNumber
       (setq lstPoint       (cons (car lstCoordinates) lstPoint)
             lstCoordinates (cdr lstCoordinates)
       )
      )
      (setq lstPoints (cons (reverse lstPoint) lstPoints))
     )
     (reverse lstPoints)
    )
    
    (princ "!")
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

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

    Default Re: Change Multileader angle

    Peter
    Sorry for the late response. Thanks. I will give it a try.
    Manuel

Similar Threads

  1. 2021: Reference Line won't flex to the angle set by an angle parameter
    By robinhillrhca700396 in forum Revit Architecture - Families
    Replies: 3
    Last Post: 2022-12-20, 05:11 PM
  2. How to change Multileader Oblique Angle
    By tracidennis789461 in forum AutoLISP
    Replies: 2
    Last Post: 2020-04-27, 08:14 PM
  3. 2017: fenetre d'angle avec et sans angle droit
    By blk000000 in forum Revit Architecture - Families
    Replies: 4
    Last Post: 2017-10-16, 04:06 PM
  4. Replies: 10
    Last Post: 2011-07-01, 02:24 PM
  5. Replies: 8
    Last Post: 2007-05-18, 06:55 PM

Posting Permissions

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