Jump to content

Rearrange selection set according to block insertion point


Recommended Posts

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

block no.PNG

Posted (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 by hanhphuc
  • Thanks 1

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