Jump to content

Text 2 Attribute


Recommended Posts

Posted

Hi All,

Is anybody having lisp programme to change text to attributes?

Thanks,

Srinivas Vinjamuri

Posted

You might try over at The Swamp. www.theswamp.org

 

You'll have to join the forum though. Once you do that conduct a search using as the criteria "text to attribute". Include the quotation marks. It should bring up a post by DanB, Bull Frog containing Carl Rockstrom's Text to Attribute lisp routine. The thread is dated March 02, 2005.

  • 3 months later...
Posted

Or Command "burst"

(sorry For Bringing This Alive, Couldnt Help My Self)

Posted
Or Command "burst"

(sorry For Bringing This Alive, Couldnt Help My Self)

 

It's ok, but BURST changes Attributes to Text - not the other way around, which is what the OP was asking :wink:

Posted

This should do the trick

[b][color=BLACK]([/color][/b]defun txt2attd [b][color=FUCHSIA]([/color][/b]/ ss ct en ed[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect A TEXT to Convert to ATTDEF:   "[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=BLUE])[/color][/b]
                              [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]setq ct [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 410 ct[b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss 0[b][color=MAROON])[/color][/b]
               ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]wcmatch [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 1 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [color=#2f4f4f]"* *"[/color][b][color=MAROON])[/color][/b]
              [b][color=MAROON]([/color][/b]getstring [color=#2f4f4f]"\nString Contains Spaces - Try Again..."[/color][b][color=MAROON])[/color][/b]
              [b][color=MAROON]([/color][/b]setq ss nil[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"ATTDEF"[/color][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 8 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 10 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 11 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 7 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 40 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 41 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 50 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 51 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 70 0[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 71 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 72 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 74 [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 73 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 210 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 1 [color=#2f4f4f]""[/color][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 2 [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 1 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 3 [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 1 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]assoc 6 ed[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 6 ed[b][color=GREEN])[/color][/b]'[b][color=GREEN]([/color][/b]6 . [color=#2f4f4f]"BYLAYER"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]assoc 39 ed[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 39 ed[b][color=GREEN])[/color][/b]'[b][color=GREEN]([/color][/b]39 . 0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]assoc 62 ed[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 62 ed[b][color=GREEN])[/color][/b]'[b][color=GREEN]([/color][/b]62 . 256[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]entdel en[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]redraw[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

Posted

David, why not use:

 

(defun c:txt2attd (/ ss ct en ed)
 (while (not ss)
        (princ "\nSelect A TEXT to Convert to ATTDEF:   ")
        (setq ss (ssget [b][color=Red]"_:S"[/color][/b] (list (cons 0 "TEXT")
                              (if (setq ct (getvar "CTAB"))
                                  (cons 410 ct)
                                  (cons 67 (- 1 (getvar "TILEMODE")))))))
         (setq en (ssname ss 0)
               ed (entget en))
         (and (wcmatch (cdr (assoc 1 ed)) "* *")
              (getstring "\nString Contains Spaces - Try Again...")
              (setq ss nil)))
 (entmake (list (cons 0 "ATTDEF")
                (assoc 8 ed)
                (assoc 10 ed)
                (assoc 11 ed)
                (assoc 7 ed)
                (assoc 40 ed)
                (assoc 41 ed)
                (assoc 50 ed)
                (assoc 51 ed)
                (cons 70 0)
                (assoc 71 ed)
                (assoc 72 ed)
                (cons 74 (cdr (assoc 73 ed)))
                (assoc 210 ed)
                (cons 1 "")
                (cons 2 (cdr (assoc 1 ed)))
                (cons 3 (cdr (assoc 1 ed)))
                (if (assoc 6 ed) (assoc 6 ed)'(6 . "BYLAYER"))
                (if (assoc 39 ed) (assoc 39 ed)'(39 . 0))
                (if (assoc 62 ed) (assoc 62 ed)'(62 . 256))))
 (entdel en)
 (redraw)
 (prin1))

 

Instead of

 

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

 

Just curious :)

 

Nice code by the way :)

Posted

Those parameters for ssget didn't come around until R14 or R15 and there were only 1 or 2 then. They have added more over the years.

 

I think that they pretty cryptic looking where as AutoLISP is a fairly human readable language. 1 Reason I don't like vl and vla stuff. Way too long names for functions and not real readable. IMO. -David

 

PS I just tried it 2000 and it didn't work as advertised

  • 6 years later...
Posted

The member found another thread in another forum AND changed the nature of her question to something more relevant to the problem she was having. Thanks.

Posted

In that case, this thread has been cleaned and is now closed.

Guest
This topic is now closed to further replies.
×
×
  • Create New...