Replace (a with b) x 200

Discussion in 'AutoCAD' started by SAM90, Aug 7, 2003.

  1. SAM90

    SAM90 Guest

    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
     
    SAM90, Aug 7, 2003
    #1
  2. Have you considered the FIND command?

    --
    http://www.acadxtabs.com


    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
     
    Tony Tanzillo, Aug 7, 2003
    #2
  3. SAM90

    mmo Guest

    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.
     
    mmo, Aug 7, 2003
    #3
  4. SAM90

    SAM90 Guest

    Thanks Tony. FIND only changes the value and not the entity. - Kev
     
    SAM90, Aug 7, 2003
    #4
  5. SAM90

    SAM90 Guest

    Thanks M. This only works on attributes within blocks. I have a bunch of loose attributes not in a block. - Kev
     
    SAM90, Aug 7, 2003
    #5
  6. 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 Tanzillo, Aug 7, 2003
    #6
  7. SAM90

    Doug Broad Guest

    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

    attributes not in a block. - Kev
     
    Doug Broad, Aug 7, 2003
    #7
  8. SAM90

    SAM90 Guest

    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.
     
    SAM90, Aug 8, 2003
    #8
  9. SAM90

    Mark Propst Guest

    ouch

    i take it all back, really, no I don't want nuthing from no
    one....pl.eeezzeee...noooothingggggg
     
    Mark Propst, Aug 8, 2003
    #9
  10. SAM90

    Doug Broad Guest

    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
     
    Doug Broad, Aug 8, 2003
    #10
  11. SAM90

    SAM90 Guest

    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
     
    SAM90, Aug 8, 2003
    #11
  12. SAM90

    Mark Propst Guest

    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
     
    Mark Propst, Aug 8, 2003
    #12
  13. SAM90

    SAM90 Guest

    Thanks again
     
    SAM90, Aug 8, 2003
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.