GWelch Posted October 23, 2007 Share Posted October 23, 2007 Greetings all, I have inherited a drawing where certain objects are represented by text. Sounds odd, but the text is the "Dingbats" sort of font, where individual letters represent symbols. So, the letter "T" represents a tree (plan view), but I would like to convert these letters to editable blocks of trees, which seems infinitely more preferable to me. Is this possible - can a "find and replace" function change text to a defined block? There are hundreds of these, so you can imagine my frustration. ACAD 2004 drawing, but I have 2007 and Land Desktop if those are necessary. Thanks in advance, GWelch Quote Link to comment Share on other sites More sharing options...
GWelch Posted November 4, 2007 Author Share Posted November 4, 2007 Just bumping this in case someone can help. Thanks. Quote Link to comment Share on other sites More sharing options...
CarlB Posted November 4, 2007 Share Posted November 4, 2007 Post this in the lisp/customization forum and a few super lispers will take care of you with an elegant routine. The following Q&D lisp might get you started (untested); (defun c:T2Block () (setq TreeStylename "Dingbats");;edit this to match actual style (setq TreeSymSet (ssget "x" '((0 . "TEXT")(1 . "T")))) (setq NumSet (sslength TreeSymSet)) (setq Count 0) (repeat NumSet (setq Ename (ssname TreeSymSet Count)) (setq InsPt (cdr (assoc 10 (entget Ename)))) (entdel Ename) (command "insert" "YourBlockname" InsPt 1 1 0);;edit block name (setq Count (1+ Count)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
GWelch Posted November 7, 2007 Author Share Posted November 7, 2007 Thank you for your reply, and sorry to take so long to respond. I'll try to post there in the next few days. Quote Link to comment Share on other sites More sharing options...
CarlB Posted November 8, 2007 Share Posted November 8, 2007 And did you try the lisp I posted? Notice it needed your editing to function, to supply a style name and a block name. Quote Link to comment Share on other sites More sharing options...
dennis03 Posted July 17, 2013 Share Posted July 17, 2013 I'm a newbie onto writing LISP. I have pretty similar problem on how to replace a text with a dynamic block? This is what I want to do: I want to replace all text or mtext in a specific layer which are basically the House Number layer of my drawing and all of these text objects in autocad are (alphanumeric). The existing value should be transferred to specific block tag which is VISIBLE attribute into my block and I aim to put them into a block tag with "HOUSE_NO". After that, all of the replaced text will be deleted since the new values are already into my new blocks. Imagine working on a map with at least 5,000 house numbers to replace them into a blocks. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 17, 2013 Share Posted July 17, 2013 I'm a newbie onto writing LISP. I have pretty similar problem on how to replace a text with a dynamic block? This is what I want to do: I want to replace all text or mtext in a specific layer which are basically the House Number layer of my drawing and all of these text objects in autocad are (alphanumeric). The existing value should be transferred to specific block tag which is VISIBLE attribute into my block and I aim to put them into a block tag with "HOUSE_NO". After that, all of the replaced text will be deleted since the new values are already into my new blocks. Imagine working on a map with at least 5,000 house numbers to replace them into a blocks. Welcome to CADTutor. This sounds like an onerous task, but I would guess that if you visited Lee Mac's excellent site there may well be some tools there to help you. http://www.lee-mac.com/programs.html#general Not sure which to suggest, but give them a look. Thanks Lee! Quote Link to comment Share on other sites More sharing options...
neophoible Posted July 17, 2013 Share Posted July 17, 2013 (edited) This is a simple, quick revision of the routine to achieve what you want: (defun c:T2B (/ Ename InsPt Count TreeSymSet NumSet TextValue Elist) ; (setq TreeStylename "Dingbats");;edit this to match actual style (setq TreeSymSet (ssget "X" '((0 . "TEXT")(8 . "HouseNumber")))) (setq NumSet (sslength TreeSymSet)) ; Edit LayName ; (princ NumSet) (setq Count 0) (repeat NumSet (setq Ename (ssname TreeSymSet Count) Elist (entget Ename) InsPt (cdr (assoc 11 Elist)) TextValue (cdr (assoc 1 Elist)) ) ; (princ Count) ; (entdel Ename) (command "_.INSERT" "APD" InsPt 1 0 TextValue) (setq Count (1+ Count)); ;edit block name ) (command "ERASE" TreeSymSet "") (princ) ) You'll need to either name your Block and Layer the same or change them in the program. It assumes the TEXT has the proper justification to match. A couple of lines have been commented out, as they do not apply for your situation. I also localized the variables. If you have problems with incorrect insertion points, try turning OSNAP OFF before running. Edited July 22, 2013 by neophoible commented out princs--can use if problem changed names to match below Quote Link to comment Share on other sites More sharing options...
dennis03 Posted July 22, 2013 Share Posted July 22, 2013 Thanks to both of you Dadgad and Neo, I have edited and try the code above, but it doesn't replace all the text into block in my drawing. You might need this info; my Text layer is "HouseNumber" my blockname is "APD" it is also in "HouseNumber" Layer Text justify: "Middle Center". Thanks! Quote Link to comment Share on other sites More sharing options...
neophoible Posted July 22, 2013 Share Posted July 22, 2013 You're welcome, dennis03. Hope this now works. I edited the code above to match the layer name and block name you listed. Middle Center should work great for this. Quote Link to comment Share on other sites More sharing options...
dennis03 Posted August 4, 2013 Share Posted August 4, 2013 I have tried to run the edited code above, but it doesn't replace the text into Block nor insert a block. I'm trying to understand the code and I have a few questions. What does setq TreeStylename "Dingbats" mean in the code? Also the (command "_.INSERT" "APD" InsPt 1 0 TextValue) seems, not doing the job done. So I try to experiment and replace it from the original code. And it does insert blocks in my drawing, I say most of it 60%, but not all text. The justification are all the same, that puzzled me why it doesn't replace them all. In case you have overlooked; I also want to moved or retain the existing TEXT value into my BLOCKS with defined Tag attributes "HOUSE_NO". Thanks Neo for the reply. Quote Link to comment Share on other sites More sharing options...
neophoible Posted August 5, 2013 Share Posted August 5, 2013 I have tried to run the edited code above, but it doesn't replace the text into Block nor insert a block.I'm trying to understand the code and I have a few questions. What does (setq TreeStylename "Dingbats") mean in the code? I added code tags. This line is actually commented out using a semicolon. It was not active and is incomplete, but must have been intended to help set the Text Style long ago. Also the (command "_.INSERT" "APD" InsPt 1 0 TextValue) seems, not doing the job done. So I try to experiment and replace it from the original code. And it does insert blocks in my drawing, I say most of it 60%, but not all text. The justification are all the same, that puzzled me why it doesn't replace them all. In case you have overlooked; I also want to moved or retain the existing TEXT value into my BLOCKS with defined Tag attributes "HOUSE_NO". Thanks Neo for the reply. You're welcome for the reply. Sorry it's not working as needed. I tell you what, post a sample DWG with about 10 or 12 of these blocks, including some that did not work. Also, show what you want it to look like when finished. Then I or someone else can take a closer look and try to solve your problem. Again, that's two parts to your DWG: Part 1 is what you start with, and Part 2 is what you want to end with. Quote Link to comment Share on other sites More sharing options...
NASR FARHAT Posted May 24, 2016 Share Posted May 24, 2016 What happened to the "convert text to block" code? Quote Link to comment Share on other sites More sharing options...
ReMark Posted May 24, 2016 Share Posted May 24, 2016 What happened to the "convert text to block" code? Looks like someone forgot to come back like they said they would. Quote Link to comment Share on other sites More sharing options...
NASR FARHAT Posted May 24, 2016 Share Posted May 24, 2016 Hi ReMark, I need exactly the same lisp routine requested initially in this thread, i.e. convert a text or Mtext to a pre-defined block with two attributes where one of them includes the original text. The block should be in the same layer as the original text and this lisp should be able to convert in one shot the entire selected texts in a given drawing. thanks, Nasr Quote Link to comment Share on other sites More sharing options...
ReMark Posted May 24, 2016 Share Posted May 24, 2016 Would you like it to order a pizza too? Your description of what you need the lisp routine to do is a little bit more involved than that stated in the first post of this thread which by the way I did find a solution to. Problem is, it is not nearly the solution you require. Sorry. 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.