Hi,I am trying to re-order the attributes in the AutoCAD blocks. Everytime i edit a existing block or try to create a new block (part copied from other blocks and renaming it as a new block) the order in which the attributes are displayed is shuffled completely.
This happens because the reference created for each of the attributes gets changed once i try to edit a block.
I have tried options like 'BATTMAN' 'ATTSYNC' 'BATTORDER' but the problem is i have a bunch of blocks each with 96 -150 pins in them (Each pins has an attribute reference). So it is really pain using all the above mentioned commands to arrange all the attributes in Ascending order.
Any ideas on how to resolve this using a LISP program ?! Is there a way to re-order them using the tag names ?!
For Instance, please check for the drawing attached.
I need to have this block's attributes re-ordered from Pin1-Pin90 in an ascending order.
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by 3wood. Go to Solution.
Hello
When you create the Block you have to select all graphic and text entities (NO ATTDEF) and then each ATTDEF one by one in the order you need !
OK you have 90 clicks but it's one time !
Of course if you have a lot of bad blocks to re-order, you need a Lisp/VLisp routine ...
Bye, Pat
Patrice BRAUD
@udaymach wrote:
...... This happens because the reference created for each of the attributes gets changed once i try to edit a block....
Makes me wonder what kind of "EDIT" do you do on the block that it messes up the order, are you introducing new attributes by any chance?
I saw your post a few days ago here: http://forums.autodesk.com/t5/AutoCAD-2010-2011-2012/Re-orderin-g-block-Attributes/m-p/4804883#M1028...
I thought you had already got the solution.
You can try SORTTAG.vlx to sort block attribute tag names in an ascending order. You need got a free registration to utilize it in full function.
After sorting, you can then use ATTSYNCALL to update/synchronize attribute tags in all block inserts.
I have tried your sample drawing and here is the sorted result. I also put a test block in it which only contains 10 attributes so you can test the trial version on it.
@udaymach wrote:
I need to have this block's attributes re-ordered from Pin1-Pin90 in an ascending order.
(defun c:oAtt (/ num blk bn all nat blkn) ;;; pBeFeb2014 ;;; (setq num (lambda (str) (vl-list->string (vl-remove-if-not '(lambda (s) (<= 48 s 57)) (vl-string->list str))))) (if (setq blk (ssget "_:S" '((0 . "INSERT")(66 . 1)))) (progn (vlax-for itm (setq blkn (vla-item (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)) ) (setq bn (cdr (assoc 2 (entget (ssname blk 0))))) ) ) (If (eq (vla-get-ObjectName itm) "AcDbAttributeDefinition") (progn (setq all (cons (mapcar '(lambda (x) (vlax-get-property itm x) ) '("Tagstring" "TextString" "Height" "Mode" "PromptString" "StyleName" "Layer" "InsertionPoint" ) ) all)) (vla-delete itm) ) )) (setq all (vl-sort all '(lambda (o p) (< (atoi (num (car o))) (atoi (num (car p))))))) (mapcar (function (lambda (lst) (setq nat (vla-AddAttribute blkn (caddr lst) (nth 3 lst) (nth 4 lst) (last lst) (car lst) (cadr lst) ) ) (vlax-put nat 'StyleName (nth 5 lst)) (vlax-put nat 'Layer (nth 6 lst)) ) ) all ) (command "_.attsync" "Name" bn) ) )(princ) ) (vl-load-com)
HTH
Hello, I'd like to ask two questions:
1. can attribute width factor be added? otherwise it is changed by lisp to 1.
2. if it is possible to modify the lisp to sort tags in multiple blocks (different blocks with same attribute tags in bad order) and set order of a pick-selected or Named block, or at least the order written in a string in the lisp? In other words, non-alphanumeric order. I guess that would be a totally different program from one in first post.