Jump to content

Lisp to reorder a column of text?


ILoveMadoka

Recommended Posts

Does someone have a routine (or know of a way) to reorder a column of text items?

 

ie:

Line 1

Line 2

Line 3

Line 4

 

to

 

Line 4

Line 3

Line 2

Line 1

 

I have a large table of text that I need to flip the column order.

Has someone posted something along these lines?

Is there an Autocad command I don't know about?

 

I have had no luck in any of the search terms I have used..

 

 

 

Thanks for all the help you guys provide... :)

Link to comment
Share on other sites

Lee Mac to the rescue once again!!!

 

Dynamic Text Alignment v1.6

 

http://www.lee-mac.com/dynamictextalignment.html

 

I had to jump through some hoops but Lee's program made it all possible.

 

Could your next update allow a text column to be rotated 360 degrees instead of limiting it 180?

(seems that is how it worked)

 

I had to rotate the text in place 180 degrees then use Autocad to rotate the entire column 180.

Awesome! Still quite a time saver!

 

Thanks Lee!

 

ps: It was all regular text entities

Link to comment
Share on other sites

I'm glad my Dynamic Text Alignment program came in handy!

 

Here is another way to achieve the same result:

([color=BLUE]defun[/color] c:revtxt ( [color=BLUE]/[/color] e i l s )
   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"TEXT"[/color]))))
       ([color=BLUE]progn[/color]
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s))
               ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))))
                     l ([color=BLUE]cons[/color] ([color=BLUE]list[/color] ([color=BLUE]assoc[/color] ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 0 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 71 e))) ([color=BLUE]=[/color] 0 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 72 e)))) 10 11) e) ([color=BLUE]assoc[/color] -1 e)) l)
               )
           )
           ([color=BLUE]mapcar[/color]
              '([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]entmod[/color] ([color=BLUE]list[/color] ([color=BLUE]cadr[/color] a) ([color=BLUE]car[/color] b))))
               ([color=BLUE]setq[/color] l ([color=BLUE]vl-sort[/color] l '([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]<[/color] ([color=BLUE]caddar[/color] a) ([color=BLUE]caddar[/color] b)))))
               ([color=BLUE]reverse[/color] l)
           )
       )
   )
   ([color=BLUE]princ[/color])
)

Link to comment
Share on other sites

This prompted me to a slightly different question you have 3 individual columns of text but only want to sort on 1st column wrote a export columns that joins the text into single row then using Lee-Mac's would allow sort. Any one wants it post request here. It was done to export to excel to sort.

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