harrison-matt Posted April 27, 2010 Share Posted April 27, 2010 Does anyone know a way to convert text or mtext into an attribute instead of creating an attribute and placing the text in the same location? Is there a way to code this through VL, or DXF? If there is any tips on how or a way to start, please point me in the right direction. Thank you, Matthew Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 No dice. You would have to take all info. from the text object and create an attribute. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 27, 2010 Share Posted April 27, 2010 Give this a shot: [i][color=#990099];; Txt2Att ( Lee Mac )[/color][/i] [i][color=#990099];; Converts Single-line Text to Attribute Definition[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:txt2att [b][color=RED]([/color][/b] [b][color=BLUE]/[/color][/b] StringSubst RemovePairs ss ent eLst str dx73 [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Lee Mac ~ 27.04.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] StringSubst [b][color=RED]([/color][/b] new pat str [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-string-search[/color][/b] pat str[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] str [b][color=RED]([/color][/b][b][color=BLUE]vl-string-subst[/color][/b] new pat str[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] str [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] RemovePairs [b][color=RED]([/color][/b] lst pairs [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] pair [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-position[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pair[b][color=RED])[/color][/b] pairs[b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] lst [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#a52a2a]"_:L"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"TEXT"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] i [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]ssname[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] eLst [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] ent[b][color=RED])[/color][/b] str [b][color=RED]([/color][/b]StringSubst [b][color=#a52a2a]"_"[/color][/b] [b][color=#a52a2a]" "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] eLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] dx73 [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]73[/color][/b] eLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] eLst [b][color=RED]([/color][/b]RemovePairs eLst [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#009900]1[/color][/b] [b][color=#009900]73[/color][/b] [b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmake[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]append[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ATTDEF"[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] eLst [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]70[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]74[/color][/b] dx73[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]1[/color][/b] str[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]2[/color][/b] str[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]3[/color][/b] str[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entdel[/color][/b] ent[b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=#009900]-1[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 There you go. Text replaced with attributes. Nice coding Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 27, 2010 Share Posted April 27, 2010 There you go. Text replaced with attributes. Nice coding Lee. Cheers Alan - its actually come up in the past, so I refined some old code - its amazing how your coding standard changes over time... Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 Cheers Alan - its actually come up in the past, so I refined some old code - its amazing how your coding standard changes over time... HaHa no kidding. I find myself apologizing for posting older code. Slick thinking on RemovePairs. A nice inverse of what I was thinking in that thread at the Swamp last week, when Hangman (I think) was trying to edit dxf codes. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 27, 2010 Share Posted April 27, 2010 Thanks mate - that approach works Ok to do it with Text, because Text and Attdefs share quite a lot of DXF codes, but MText might be more troublesome... Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 Thanks mate - that approach works Ok to do it with Text, because Text and Attdefs share quite a lot of DXF codes, but MText might be more troublesome... Most definitely. Plus, you'd be forced to strip out all formatting. What a pain. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 27, 2010 Share Posted April 27, 2010 Most definitely. Plus, you'd be forced to strip out all formatting. What a pain. Arrgghhh the formatting.... I'm so sick of it Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 Arrgghhh the formatting.... I'm so sick of it LoL, I can imagine. Quote Link to comment Share on other sites More sharing options...
harrison-matt Posted April 27, 2010 Author Share Posted April 27, 2010 Lee, I really need to pick your brain on VL, I admit it is fantastic. Thanks. Kind Regards, Matthew Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 27, 2010 Share Posted April 27, 2010 Thanks Matt, but why? Quote Link to comment Share on other sites More sharing options...
harrison-matt Posted April 27, 2010 Author Share Posted April 27, 2010 Well Lee, I feel more can be done through VL and I would love to have a shot at it, however, i haven't found much material or well written code with examples. I also hear it is much faster, more resilient at catching errors, and more complex. All of which intrigues me. -Matt Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 Well Lee, I feel more can be done through VL and I would love to have a shot at it, however, i haven't found much material or well written code with examples. I also hear it is much faster, more resilient at catching errors, and more complex. All of which intrigues me. -Matt Have you looked through the AutoCAD help file(s), specifically under AutoLISP, Visual LISP, DXF? Quote Link to comment Share on other sites More sharing options...
harrison-matt Posted April 27, 2010 Author Share Posted April 27, 2010 Ofcourse. Yet, nothing can beat sitting in front of a complex code with descriptions. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 27, 2010 Share Posted April 27, 2010 Help files, Visual LISP Developer's Bible and AutoCAD 2000 AutoLISP Reference (includes VLisp) are your best resources. They are floating around the internet, but if you'll PM me your email addy, I'll shoot them over. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 28, 2010 Share Posted April 28, 2010 I agree with Alan, that the VLIDE help files are your best resource, coupled with coding examples - just search the forums, Alan and I have posted thousands of examples. Oh and FYI AutoLISP using DXF is actually faster than VL Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 28, 2010 Share Posted April 28, 2010 I agree with Alan, that the VLIDE help files are your best resource, coupled with coding examples - just search the forums, Alan and I have posted thousands of examples. HaHa, how very true. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.