AutoLISP: Bump Attributes Values

Here is another Lee-Mac routine. This routine is not on Lee’s website but is from the Augi forums [found here].

http://wp.me/p1aURt-kg

This routine is pretty awesome for moving attributes up or down in position. It will not “move” the entire attribute, it will move the VALUE only. The trick for this routine to work is to select the attributes in the order that you would like them to be “bumped” and to make a block for each of the attribute types. What I mean by “types” is shown in the example below: I have an example of a generic revision section for a title block. Let’s say that I want the most current revision to be located in the lower right of the revisions. So I need a way to move the previously made revisions up one space so that I can enter the new revision in its proper place. The thing that might be confusing for this routine to work is that each “type” of revision needs to be its own block. So the attributes for “Revision Name” needs to be its own block and the attributes for “Revision Description” needs to be its own block etc.

The beauty of this routine is that it is universal. You can use it on any block with attributes without having to know specific attribute tag names…

Here’s how:

  • BUMP <enter> to start
  • Select the Attributes  that you want to “BUMP”
  • Hit the + or – keys to move the attributes (plus or minus)

; found at http://forums.augi.com/showthread.php?t=130526&page=2
; by Lee-Mac
; This will "bump attributes in the order that they were selected
; great for title block revisions...
(defun c:bump ( / a g ) ;; Lee Mac 2011
(cond
( (setq a (ssget "_+.:S:E:L" '((0 . "INSERT") (66 . 1))))
(setq a (vlax-invoke (vlax-ename->vla-object (ssname a 0)) 'getattributes))
(princ "\nPress [+/-] to Bump Attributes Up & Down. <Done>")
(while (member (setq g (grread nil 10)) '((2 45) (2 95) (2 43) (2 61)))
(mapcar 'vla-put-textstring a
(mapcar 'vla-get-textstring
(if (member g '((2 45) (2 95))) (cons (last a) a) (append (cdr a) (list (car a))))
)
)
)
)
)
(princ)
)
(vl-load-com) (princ)

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in Attributes, AutoLISP, AutoLISP: Attributes, AutoLISP: Blocks, AutoLISP: Manage, AutoLISP: Modify. Bookmark the permalink.

Leave a comment