Replace (a with b) x 200

SAM90

Usenet Archive
Joined
Jul 24, 2003
Messages
24
Reaction score
0
Hi- somebody placed a couple of hundred attributes in the drawing with the Tag "D" and the Value "D" at various locations and rotations. I need to replace them all with Text, Contents "D". Can one of the LIsp guys provide me with a routine or is there one knocking about? - TIA - Kev
 
Have you considered the FIND command?

SAM90 said:
Hi- somebody placed a couple of hundred attributes in the drawing with the Tag "D" and the Value "D" at various
locations and rotations. I need to replace them all with Text, Contents "D". Can one of the LIsp guys provide me with a routine or is there one knocking about? - TIA - Kev
 
Hello SAM90,

If you have AutoCAD Express Tools, then pull-downmwnu "Express" -> "Blocks" -> "Explode Attributes to Text" does exactly what you ask. You can use FILTER and pre-select on block name to insure that you only explode the propper attribites

With friendly greetings, M. Moolhuysen.
 
Thanks Tony. FIND only changes the value and not the entity. - Kev
 
Thanks M. This only works on attributes within blocks. I have a bunch of loose attributes not in a block. - Kev
 
There's no such thing as "loose attributes not in a block".

Attributes can only exist within an insert/seqend sequence, so perhaps you are referring to attribute definitions rather than attributes?
 
Tony,
Of course you are correct. It is interesting, however, that the object model refers to them as "attribute" objects and what we know as attributes, it calls "attributereference" objects.

SAM90,
Sounds like someone exploded the blocks and then edited the attributes to have the text they wanted or copied attributes around as if they had been dtext and changed the tag values. If you are interested in learning the lisp necessary to perform the task, then you can obtain a selection set for attribute definitions by (setq ss (ssget (list (cons 0 "attdef"))))

Then you can work through the selection set in a repeat or while loop and (entget (ssname ss i)) each attdef.

For each of those entities, you need to change only a few of the codes in the entity list of the attribute definition to make a valid text enitity list. Once you have the entity list, then you can create the new text entity and delete the old attribute definition.

(entmake <entity list>) and then
(entdel <attribute ename>)

The codes to change are 0, some of the 100 codes, the tag code 2 becomes code 1, and justification code 74 becomes
73.

There is no discernable difference on a plot, however,
between what you have and the text entities they would
be converted into.

Regards,
Doug

Tony Tanzillo said:
There's no such thing as "loose attributes not in a block".

Attributes can only exist within an insert/seqend sequence, so perhaps you are referring to attribute definitions rather than attributes?
attributes not in a block. - Kev
 
Your right, it's an attribute definition, I didn't realise there was a difference. If I select one then check the properties box its described as an attribute. If I list it, it's described as an attribute definition. When I double-click it the Edit Attribute Definition dialogue appears and the command _.ddedit appears on the command line.
 
Doug Broad said:
Mark,
Be careful of amusing notices charging for posting other authors' copyrighted material. Even in jest, you might find it come back to bite you. :-)

ouch

i take it all back, really, no I don't want nuthing from no one....pl.eeezzeee...noooothingggggg
 
Mark,
Be careful of amusing notices charging for posting other authors' copyrighted material. Even in jest, you might find it come back to bite you. :-)

SAM90,
If Jeff/Mark's routine does not fill your needs,
I have a routine to account for all possibilities. If you are interested, email privately. Terry Dotson also has some stuff to fix it and you might find some free stuff if you look hard enough.

Regards,
Doug
 
Mark Thanks for the lisp which worked a treat. For yor info here's the last few lines of the command line after running "Command: text
Current text style: "STANDARD" Text height: 125.000 Specify start point of text or [Justify/Style]:
Specify height &lt;125.000&gt;: 125.0000000000000
Specify rotation angle of text &lt;0.00000000&gt;:
Enter text: D

Command: Undo Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] &lt;1&gt;: End

Command: ; error: extra right paren on input"

It doesn't mean much to me but I'm afraid you forfeit the $10k for the error! - Kev
 
Mark Thanks for the lisp which worked a treat. For yor info here's the last few lines of the command line after running "Command: text
Current text style: "STANDARD" Text height: 125.000
Specify start point of text or [Justify/Style]:
Specify height <125.000>: 125.0000000000000
Specify rotation angle of text <0.00000000>:
Enter text: D
Command: Undo Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: End
Command: ; error: extra right paren on input"

oops!

It doesn't mean much to me but I'm afraid you forfeit the $10k for the error! - Kev

just as well, I'm got real tired of jail food long ago...

here's a little better version

;modified practically beyond recognition to replace all attdefs with text ;doesn't handle modified justification

(Defun C:FixAtt2 ( / ss ss-e ss-e-inf ss-e-tag ss-e-ins ss-e-hgt ss-e-rot oe
*error* texte textl cleanup)
(defun *error*(msg)
(if oe(setvar"Cmdecho" oe))
(if ol(setvar"Clayer" ol))
(if ot(setvar"Textstyle" ot))
)

;Tony Tanzillo's idea
(defun cleanup(msg)
(*error* msg)
)

(setq oe(getvar"Cmdecho"))
(setvar "cmdecho" 0)
(setq ol(getvar"Clayer"))
(setq ot(getvar"Textstyle"))

(command"Undo""Begin")
(setq ss (ssget "X" (list (cons 0 "ATTDEF") )))
(while (/= (setq ss-e (ssname ss 0)) nil)
(setq
ss-e-inf (entget ss-e)
ss-e-tag (cdr (assoc 2 ss-e-inf))
ss-e-ins (cdr (assoc 10 ss-e-inf))
ss-e-hgt (cdr (assoc 40 ss-e-inf))
ss-e-rot (cdr (assoc 50 ss-e-inf))
ss-e-ts (cdr (assoc 7 ss-e-inf))
ss-e-tsh(cdr(assoc 40(entget(tblobjname"style" ss-e-ts)))) ) (setvar "clayer" (cdr (assoc 8 ss-e-inf))) (setvar "textstyle" ss-e-ts ) (command "erase" ss-e "") (if (= ss-e-tsh 0) (command "text" ss-e-ins ss-e-hgt ss-e-rot ss-e-tag) (progn (command "text" ss-e-ins ss-e-rot ss-e-tag) (setq texte (entlast) textl(entget texte)) (entmod(subst(cons 40 ss-e-hgt)(assoc 40 textl)textl)) ) );if (entmod(subst(cons 50 ss-e-rot)(assoc 50 textl)textl)) (ssdel ss-e ss) );while (command"Undo""End") (cleanup nil) (princ)
);defun
 

Latest threads

Back
Top