Jump to content

Recommended Posts

Posted

I have a lot of texts and polyline-s in one layer. How to I convert only the polylines to Leaders?

Posted

Extract the XYZ of each PLine vertex and draw a leader accordingly.

Posted

The user would have to select which text was to be used.

 

Look into the vla-addLeader function.

Posted

Something like this perhaps:

 

(defun c:toLeader (/ lst2pt ENT PTS TXT TYP)
 (vl-load-com) ;; Lee Mac  ~  24.02.10

 (defun lst2pt (lst flag)
   (if lst
     (cons (list (car lst) (cadr lst) (if flag (caddr lst) 0.0))
           (lst2pt (if flag (cdddr lst) (cddr lst)) flag))))

 (setq *doc (cond (*doc) ((vla-get-ActiveDocument
                            (vlax-get-acad-object)))))
 (while
   (progn
     (setq ent (car (entsel "\nSelect Polyline for Leader: ")))

     (cond (  (eq 'ENAME (type ent))

              (if (wcmatch (setq typ (cdr (assoc 0 (entget ent)))) "*POLYLINE")
                (progn
                  (setq pts
                    (lst2pt
                      (vlax-get
                        (vlax-ename->vla-object ent) 'Coordinates)

                      (if (eq "POLYLINE" typ) t nil)))

                  (while
                    (progn
                      (setq txt (car (entsel "\nSelect Text for Leader: ")))

                      (cond (  (eq 'ENAME (type txt))

                               (if (eq "MTEXT" (cdr (assoc 0 (entget txt))))
                                 (progn
                                   
                                   (vla-AddLeader
                                     
                                     (if (zerop (vla-get-ActiveSpace *doc))
                                       (if (eq :vlax-true (vla-get-mspace *doc))
                                         (vla-get-ModelSpace *doc)
                                         (vla-get-PaperSpace *doc))                                        
                                       (vla-get-ModelSpace *doc))
                                     
                                     (variant
                                       (vlax-safearray-fill
                                         (safearray vlax-vbDouble
                                           (cons 0 (1- (* 3 (length pts)))))
                                         (apply (function append) pts)))
                                     
                                       (vlax-ename->vla-object txt)
                                     
                                     acLineWithArrow)

                                   (entdel ent))

                                 (princ "\n** Object Must be MText **")))))))
                
                (princ "\n** Object Must be a *Polyline **"))))))
 (princ))

                                   

  • 4 months later...
Posted

Nice lisp Lee. Can you modify this so that it doesnt ask for text? Just want to change the polylines into leaders. Can you have the lisp leave the new leader on its original layer instead of layer '0'?

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