Author Topic: Need a lisp to sort selection from left to right and bottom to top  (Read 44 times)

0 Members and 1 Guest are viewing this topic.

Vikram

  • Newt
  • Posts: 50
Hi guys, I have drawings with design of big sheets in them. I have to DXFOUT them to and have to select each entity manually from left top right and bottom to top to process it in another software. Is there any lisp to sort the selection in this way?
When I try to select all they get selected in the order they were drawn.

Selection should be like from first bottom left entity to first top left entity in right direction

I'm using AutoCAD 2022 and I have attached the image and drawing file of the same. Any help would be appreciated very very much! :-)
PS: I'm newbie in lisp programming.

BIGAL

  • Swamp Rat
  • Posts: 894
  • 30 + years of using Autocad
Re: Need a lisp to sort selection from left to right and bottom to top
« Reply #1 on: January 23, 2022, 06:55:07 PM »
There is the VL-sort function which can sort on X & Y so you would make a list of say ((X Y entityname).....

This should be lower left sort so you should be able to work out which corner you want. Look at the < & = combo may need >

Code: [Select]
; sorts on 1st two items
(vl-sort lst
'(lambda (a b)
    (cond
      ((< (car a) (car b)))
      ((= (car a) (car b)) (< (cadr a) (cadr b)))
    )
  )
)
A man who never made a mistake never made anything

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7240
  • AKA Daniel
You can create a selection set, then add entities in the order you want
Retired