Jump to content

Arrange items of a selection set


wimal

Recommended Posts

Actually I have a selection set of texts.

I need arrange them ascending order to X coordinates of insertion points of texts.

 

(defun c:demo (/ ss i lst [color="red"]en[/color])
 (if (setq ss (ssget ":L" '((0 . "TEXT"))))
   (progn (repeat (setq i (sslength ss))
    [color="red"](setq en[/color] (ssname ss (setq i (1- i))[color="red"])[/color]
     lst (cons [color="red"](cons en[/color] (cdr (assoc 10 (entget [color="red"]en[/color])))[color="red"]) [/color]lst))
     )
   (mapcar 'print ([color="blue"]vl-sort[/color] lst ''((a b) (< ([color="red"]cadr[/color] a) ([color="red"]cadr[/color] b)))))
   )
   ) 
 (princ)
 )

EDIT: in red

Edited by hanhphuc
add ename as OP's requested
Link to comment
Share on other sites

Many thanks for your code.

Yes it is working nicely. I need few more facility. The entities added to selection set also to be rearrange

according to lst.

Link to comment
Share on other sites

Many thanks for your code.

Yes it is working nicely. I need few more facility. The entities added to selection set also to be rearrange

according to lst.

 

something like this?

[color="green"];(<Entity name: 7eff6968> 349.007 -619.006 0.0) ? [/color]

code updated post#2 (in red)

Link to comment
Share on other sites

Thanks the code is working now.next I need keep one item each which have same insertion points and filter others.

Please can you help.

Link to comment
Share on other sites

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