TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AcDbZombieEntity on July 10, 2013, 08:11:47 AM
-
Hi,
i've got here many blocks with many attributes, a lot of them have the same attributes but sorted crazy unique in each block definition.
- Is there any method to "resort" them all with lisp, alphabetical order by name and not the promt or value?
- Is there an way to get battman working with command?
P.S. with out an lost of allready entered values :evil:
-
- Is there any method to "resort" them all with lisp, alphabetical order by name and not the promt or value?
e.g .
(setq l '("c" "e" "d" "a" "f" "b"))
(acad_strlsort l)
-
Are you meaning tagname from attributdefinition you would like sort. Do you want rebuild a block with attributes.
Another way without lisp is, you take a copy of block, explode them and than use command attredef and you can by clicking on attdef byself choice direction which attdef should be sort.
Itīs a bit difficult to do that with lisp, you need a function which sort all tagnames from attdef and than you have to entmod them. Iīm not sure if itīs the best way.
-
I don't think the BAttMan options are available to Lisp.
The "simplest" method would be for the lisp to recreate the block definition using the BLOCK command, but select the attdef's in the correct order:- Insert a temporary block
- Explode it
- Select previous
- Remove all attdef objects from that selection set and add them to a list
- Sort the list on the attributes' tag names
- Add them back in order using ssadd
- Recreate the block, overwriting the old definition
- Run attsync to update all the existing block references to the same attribute order
- Erase the temporary block
Repeat the process for each block definition.
-
The "simplest" method would be for the lisp to recreate the block definition using the BLOCK command, but select the attdef's in the correct order
However, this method would not work for attributed dynamic blocks.
Try the following:
;; Sort Tags - Lee Mac
(defun c:sorttags
( / cmd lst
) )
)
)
)
)
)
)
)
-
Awesome Lee, thanks a lot. learned something new with
(foreach att (vl-sort lst '(lambda ( a b ) (< (vla-get-tagstring a) (vla-get-tagstring b))))
(vla-copy att)
(vla-delete att)
)
-
You're very welcome.
Great username BTW :-P
-
Welcome to the swamp brother zombie!
-
Awesome Lee, thanks a lot. learned something new with
(foreach att (vl-sort lst '(lambda ( a b ) (< (vla-get-tagstring a) (vla-get-tagstring b))))
(vla-copy att)
(vla-delete att)
)
:kewl:
-
Awesome Lee, thanks a lot. learned something new with
(foreach att (vl-sort lst '(lambda ( a b ) (< (vla-get-tagstring a) (vla-get-tagstring b))))
(vla-copy att)
(vla-delete att)
)
:kewl:
:-)