Jump to content

Multileader - How update leader line Vertices - Updating Landing Position by adding xd and yd values?


Recommended Posts

Posted

I would like to update the multi leader line landing x,y by reading the existing and adding an x,y shift. I need help with the updating part.

 

;; Update the landing start point (2nd point in the leader line)
(defun c:foo ( / ssA ss i ent obj obType verts ptList newPt flatList newSA dx dy pt1 pt2 NewLanding)
  
  (defun *error* ( msg )
    (if (not (member msg '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
    )
    (princ)
  )
  
  ;Select Multileaders
  (setq ssA (ssget '((0 . "MULTILEADER")))) 

  (if ssA
    (progn
      (setq ss (ssadd))  
      (setq i 0)
      (while (< i (sslength ssA)) 
        (setq ent (ssname ssA i)
         obj (vlax-ename->vla-object ent)
         obType (vla-get-ContentType obj))
        (if (= obType 2) (ssadd ent ss))
        (setq i (+ i 1))
      )
      
      ;Define X and Y Shfits
      (setq pt1 (getpoint))
      (prompt "\nPick 1st point (base): ")
      (setq pt2 (getpoint pt1 "\nPick second point (target): "))

      (setq dx (- (car pt2) (car pt1)))
      (setq dy (- (cadr pt2) (cadr pt1))) 
      
      (princ (strcat "\nX shift: " (rtos dx 2 4)))
      (princ (strcat "\nY shift: " (rtos dy 2 4)))
      
      
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i)
              obj (vlax-ename->vla-object ent)
            verts (vlax-invoke obj 'GetLeaderLineVertices 0))

        (princ (length verts))
        (princ "\n") (princ verts)
        (setq NewLanding (list (+ (nth 3 verts) dx) (+ (nth 4 verts) dy) 0 ))
        ; Update PoVerticiesint Here
        
        ;; End of Verticies Update
        (setq i (+ i 1))
      ) ; End loping Through SS
    )
    (princ "\nNo MLeaders found.")
  )
  
  (princ)
)

 

MultiLeader.png

Posted (edited)

Here is an update that works. (not sure how robust it is ) - Currently my ML only has a single leader line...

 

;; Update the landing start point (2nd point in the leader line)
(defun c:foo ( / ssA ss i ent obj obType verts ptList newPt flatList newSA dx dy pt1 pt2 newVerts)
  
  (defun *error* ( msg )
    (if (not (member msg '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
    )
    (princ)
  )
  
  ;Select Multileaders
  (setq ssA (ssget '((0 . "MULTILEADER")))) 

  (if ssA
    (progn
      (setq ss (ssadd))  
      (setq i 0)
      (while (< i (sslength ssA)) 
        (setq ent (ssname ssA i)
         obj (vlax-ename->vla-object ent)
         obType (vla-get-ContentType obj))
        (if (= obType 2) (ssadd ent ss))
        (setq i (+ i 1))
      )
      
      ;Define X and Y Shfits
      (setq pt1 (getpoint))
      (prompt "\nPick 1st point (base): ")
      (setq pt2 (getpoint pt1 "\nPick second point (target): "))

      (setq dx (- (car pt2) (car pt1)))
      (setq dy (- (cadr pt2) (cadr pt1))) 
      
      (princ (strcat "\nX shift: " (rtos dx 2 4)))
      (princ (strcat "\nY shift: " (rtos dy 2 4)))
      
      
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i)
              obj (vlax-ename->vla-object ent)
            verts (vlax-invoke obj 'GetLeaderLineVertices 0))

        (princ (length verts))
        (princ "\n") (princ verts)
        ; Update PoVerticiesint Here
        (setq newVerts (list (nth 0 verts)
                                 (nth 1 verts)
                                 (nth 2 verts)
                                 (+ (nth 3 verts) dx)  ; X shift
                                 (+ (nth 4 verts) dy)  ; Y shift
                                 (nth 5 verts)))       ; Keep Z coordinate
        (vlax-invoke obj 'SetLeaderLineVertices 0 newVerts)       
        ;; End of Verticies Update
        (setq i (+ i 1))
      ) ; End loping Through SS
    )
    (princ "\nNo MLeaders found.")
  )
  
  (princ)
)

 

Edited by DavidP
Posted

Although it works I end up with a line over strike issue (as show in the image bellow - Top scenario) any ideas how to solve this?

LineOverSrikeIssue.png

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...