TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: strebor71 on December 17, 2014, 03:00:12 PM

Title: lisp to change an attribute tag NOT IN A BLOCK
Post by: strebor71 on December 17, 2014, 03:00:12 PM
Hello,  I am having a hell of a time trying to find out how to write some code that will allow me to be able to change the Tag name of an attribute that is not in a block. we have several drawings that have attributes in them so that when inserted into a drawing the attribute either prompts the user for input or is auto populated from a field or what have you. I want to be able to batch change the text in one of these attributes for several drawings. the tag is the same in all drawings so it should be simple. All the lisp and conversations seem to deal with how to change the attributes for an existing block, not just attributes themselves. can someone please point me in the right direction on how to get this done. thanks
Title: Re: lisp to change an attribute tag NOT IN A BLOCK
Post by: ronjonp on December 17, 2014, 04:05:52 PM
Here is a simple example how to change the tagstring for an attribute definition.  Welcome to TheSwamp :) .
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ o str)
  2.   (if (and (setq o (car (entsel "\nPick attribute definition:")))
  3.            (setq o (vlax-ename->vla-object o))
  4.            (= (vla-get-objectname o) "AcDbAttributeDefinition")
  5.            (/= "" (setq str (getstring "\nEnter tagname: ")))
  6.       )
  7.     (vla-put-tagstring o str)
  8.   )
  9.   (princ)
  10. )
Title: Re: lisp to change an attribute tag NOT IN A BLOCK
Post by: David Bethel on December 17, 2014, 04:55:15 PM
While closely related, ATTDEF and ATTRIB are (2) different entity types and must modified accordingly.   As you are finding out,  editing an ATTRIB has no affect on the corresponding ATTDEF without some type of sync command.  -David
Title: Re: lisp to change an attribute tag NOT IN A BLOCK
Post by: sbanister on December 18, 2014, 10:44:37 AM
'change the Tag name of an attribute that is not in a block'

I don't understand why you're not using simple text.

There's not much point in attributes if they're not part of a block
Title: Re: lisp to change an attribute tag NOT IN A BLOCK
Post by: dgorsman on December 18, 2014, 01:22:59 PM
'change the Tag name of an attribute that is not in a block'

I don't understand why you're not using simple text.

There's not much point in attributes if they're not part of a block

I think the gist is batch modifying a library of block definitions.  We have several thousand of these; thankfully, I also have people to do the grunt work when this comes around.