Autocad Lisp Change Attribute

  суббота 13 октября
      26

I've had a simple lisp I've been using for years that suddenly disappeared. It required that you identify a block name, tag name, and the value that you want the tag to be. All of this is performed via command line, so it is scriptable. The conjuring torrent. Since I lost it, I've been experimenting with -attedit. This command comes frustratingly close to what I'm looking for, except it only appends an existing tag, or replaces a specific string within the tag; I can't get it to replace the entire tag, regardless of its value.

1> does anyone have a lisp routine that does what I describe? Or 2> does anyone know how to make -attedit replace a tag value without regard to what the value currently is (like a * wildcard)? Attached is a simple mockup DWG of what I am referring to. It contains two blocks--one called ellipse, and one called rectangle. Each block has three attributes, tag1, tag2, and tag3. The LISP needs to be able to change a specific tag from a specific block definition, such that a different block definition with the same tag names is not affected, e.g. Change the value of the attribute tag 'tag2' in block 'rectangle' to the value 'abc' without changing the attribute tag 'tag2' in the block definition 'ellipse'.

The Attribute Tag field specifies the tag name of the attribute to be modified (Note: this is not the attribute prompt string). This field is also not case-sensitive and, as per the restrictions on attribute tag names, the attribute tag cannot contain spaces. Finally, the Value field specifies the new content for the attribute. Yes, even if your site is still purely AutoCAD-based. In this post I’ll describe the (inspector) LISP function. This was added in the V18 cycle but was significantly enhanced in V19. It’s probably the most useful LISP function you’ve never heard of. Although it’s LISP, that doesn’t mean you have to be a programmer to benefit from it.

The choice of which block definition and which attribute tag is user supplied via command line. This allows for automated scripting. Does this help? Hi, You did not mention which tag you would like to change so I considered TAG1 as a start at the moment, so I have no problem to change it as you wish if needed. (defun c:TesT (/ st ss i n e x);; Tharwat 08. 2011;; (if (and (not (eq (setq st (getstring t ' n Enter string for attribute TAG1:')) ' ) ) (setq ss (ssget '_:L' '((0. 'INSERT') (66.

1)))) ) (repeat (setq i (sslength ss)) (setq n (entnext (ssname ss (setq i (1- i))))) (while (not (eq (cdr (assoc 0 (setq e (entget n)))) 'SEQEND' ) ) (if (eq (cdr (assoc 1 e)) 'TAG1') (entmod (subst (cons 1 st) (assoc 1 e) e)) ) (setq n (entnext n)) ) ) ) (princ) ). Tharwat, When I run your lisp routine, nothing happens to the tag name after I select it. Hallex, Your lisp works great. As far as I can tell, it requires direct change of the lisp code to change the parameters, as opposed to being users choice within Autocad--differen't, but I can get used to it, so thank you very much. As an aside, I've managed to get -attedit to work in a limited way via the following command string: (command '-attedit' 'y' 'BLOCK_NAME' 'TAG_NAME' ' '-999999,-999999' '999' ' 'v' 'r' 'TAG_VALUE' ') It only works on a single instance of a block however, which is usually ok; your solution is more flexable however.