Jump to content

Recommended Posts

Posted

Hi all,

 

Very new at this forum. I need an AutoLISP that will help me auto numbering blocks or text. I am aware of "TCOUNT which is handy, however the command only gives you 3 choices in regards to how to number, X, Y and Select order. What I need is a program that will sort and number my blocks/text by distance from a point. Thank you so much for your help.

A.jpg

Posted

Welcome to CADTutor :)

 

Try this code which should deal with Blocks and let me know how you'd get on with it .

 

Note : if the text height is not suitable for you , you can change it from one to as indicated in the code .

 

(defun c:Test (/ ss pt i sn p l lst n)
 (if (and (setq ss (ssget '((0 . "INSERT"))))
          (setq pt (getpoint "\n Specify Center point :"))
     )
   (progn
     (repeat (setq i (sslength ss))
       (setq sn (ssname ss (setq i (1- i)))
             p  (cdr (assoc 10 (entget sn)))
             l  (cons (list (distance pt p) p) l)
       )
     )
     (setq lst (vl-sort l (function (lambda (j k) (< (car j) (car k)))))
           n   0
     )
     (foreach x lst
       (entmakex (list '(0 . "TEXT")
                       (cons 10 (cadr x))
                       (cons 11 (cadr x))
                       (cons 1 (itoa (setq n (1+ n))))
                       (cons 40 1.0) ; Text height
                 )
       )
     )
   )
 )
 (princ)
)

Posted
Wow. it works amazing. Thank you so much

Great . You're welcome :)

 

I am really happy to help .

Posted

David, your observation is correct, except that Tharwat's code isn't sorting atoms, but lists, and those will be preserved after sorting, even if identical.

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