Dayananda Posted December 24, 2019 Share Posted December 24, 2019 (setq ssblock1(ssadd ent1 ssblock1 )) I have a selection set of blocks. Next I need rearrange this selection set increasing X and Y direction of insertion point to insert the serial number. as shown in the image. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 24, 2019 Share Posted December 24, 2019 (edited) 4 hours ago, Dayananda said: (setq ssblock1(ssadd ent1 ssblock1 )) I have a selection set of blocks. Next I need rearrange this selection set increasing X and Y direction of insertion point to insert the serial number. as shown in the image. 1.ssget 2.populate selection set as list 3.vl-sort function to sort increasing X-coordinates 4.loop using mapcar/ repeat / foreach / while to do it (serial number as TEXT) (defun c:test ( / i f s l a b ) (and (setq i -1 f '((x e)(assoc x (entget e))) s (ssget '((0 . "INSERT")))) (setq l (vl-sort (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) ''((a b)(< (cadr (f 10 a))(cadr (f 10 b) )))) a (cdr (f 10 (car l))) ) (foreach x l (grdraw a (setq b (cdr (f 10 x))) 1)(setq a b) ;;; Try put code your serial number here ;;; (princ (strcat "\nPut your Serial number : " (itoa (setq i (1+ i))))) ) ) (princ) ) To put serial number TEXT, try use entmake function, cons with dxf index 0, 1, 10, 40. strcat for prefix, example 'i' is incremental value, i.e: ( cons 1 (strcat "GF-S-" (itoa i)) ) Edited December 24, 2019 by hanhphuc 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.