kddsuq2727 Posted September 24, 2018 Share Posted September 24, 2018 Hi everyone, I have been lurking around this site as well as other trying to take in as much knowledge as possible. After considerable amount of time trying to modify and adapt a lisp to suite my needs I felt it was time to bring in the big guns, so here I am. I started with a lisp that would simply take a selected text and match the tab to it modified it to give me the ability to prompt me select the sheet number and then the sheet name, removing any charters that are not allowed in the Tab and adding a space/hyphen/space between the number and name. That brings us to our next set of hurtles, without bursting the text I would like to be able to pull in attributed text as well formatted mtext without having to use "StripMtext.lsp" Thanks. NLAY.LSP Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 24, 2018 Share Posted September 24, 2018 1 hour ago, kddsuq2727 said: Hi everyone, I have been lurking around this site as well as other trying to take in as much knowledge as possible. After considerable amount of time trying to modify and adapt a lisp to suite my needs I felt it was time to bring in the big guns, so here I am. I started with a lisp that would simply take a selected text and match the tab to it modified it to give me the ability to prompt me select the sheet number and then the sheet name, removing any charters that are not allowed in the Tab and adding a space/hyphen/space between the number and name. That brings us to our next set of hurtles, without bursting the text I would like to be able to pull in attributed text as well formatted mtext without having to use "StripMtext.lsp" Attributes in a block can be accessed directly by using (nentsel) and selecting the attribute. See snippet below (setq thestring (cdr (assoc 1 (entget (car (nentsel "\nSelect Attribute : ")))))) It's not possible to access the text string of formatted MText without a) stripping the formatting b) exploding the MText It is possible to Copy the MText in place then explode the copy, gather the text item(s) and recontruct the string before deleting it/them, leaving the original MText in place. Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) Ok, I figured the mtext was a no go via a simple lisp, I'm also assuming I can write it to use attributes or simple text but not either or? Thanks for the response Edited September 24, 2018 by kddsuq2727 Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) added a thanks dlanorh Edited September 24, 2018 by kddsuq2727 Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 24, 2018 Share Posted September 24, 2018 7 minutes ago, kddsuq2727 said: Ok, I figured the mtext was a no go via a simple lisp, I'm also assuming I can write it to use attributes or simple text but not either or? Thanks for the response You can use MText, it's just more convoluted getting to the text string, and would probably be easier using Visual Lisp (activex) It can all be combined into one, since nentsel returns the same as entsel for non complex entities. Select the "text" and get the object type and entity (setq ent_type (cdr (assoc 0 (entget (setq ent (car (nentsel "\nSelect Text : "))))))) Use a condition for the 4 cases (cond ( (= ent_type "TEXT") ;code to get text string for text goes here ) ( (= ent_type "MTEXT") ;code to get text string for mtext goes here ) ( (= ent_type "ATTRIBUTE") ;code to get text string for attribute goes here ) ( ;code for not a text entity goes here ) );end_cond I'm away from AutoCAD at the moment, So cannot be certain that "ATTRIBUTE" is the entity type returned by an attribute It would probably be wise to stick it all into a while loop so that if it is not a text entity it loops to allow another selection Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 24, 2018 Author Share Posted September 24, 2018 Thanks dlanorth, I'm finding that this is not a simple fix as I was hopping and quickly extending beyond my programing skills. In the meantime I'll have everyone do the copy and burst method, while I spend time learning how to work with the code that you have posted. Thanks again. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 25, 2018 Share Posted September 25, 2018 nentsel returns (0 . "ATTRIB") when you pick an ttribute. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 25, 2018 Share Posted September 25, 2018 11 hours ago, kddsuq2727 said: Thanks dlanorth, I'm finding that this is not a simple fix as I was hopping and quickly extending beyond my programing skills. In the meantime I'll have everyone do the copy and burst method, while I spend time learning how to work with the code that you have posted. Thanks again. I can sort the more complicated code for you, and will document it to make it easier to understand. I have a question however, is the MText you want to access actually a MText Item or a multiline attribute? Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 25, 2018 Author Share Posted September 25, 2018 Sorry for the delayed response. For the most part when done in attribute format I've found that the sheet name is a single line Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 25, 2018 Share Posted September 25, 2018 5 hours ago, kddsuq2727 said: Sorry for the delayed response. For the most part when done in attribute format I've found that the sheet name is a single line OK, think I understood that. I can't promise anything over the next few days as I'm pretty busy, but I may be able to get something by the end of the week. Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 25, 2018 Author Share Posted September 25, 2018 15 hours ago, BIGAL said: That would be great. I was trying to convey that most of the time its single line. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 26, 2018 Share Posted September 26, 2018 Here is a couple of examples to have a look at, may give you some ideas. Update sheet nums.lsp GETVALS.lsp Dwgindex.lsp Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 26, 2018 Share Posted September 26, 2018 OK, attached is a minimally tested documented lisp that hopefully does what you require. I have also attached the drawing used to test the lisp. I'd advise that you test it using a drawing more suited than mine. It is not perfect, as I have assumed that the attributes used will probably be part of a title box. Since it is impractical to copy, explode etc I have implimented a basic strip mtext function for multiline attributes. This may fail for some multiline attributes, particularily if there is a semi colon within the text string that is NOT part of any formatting. The lisp is split, containing a main function (c:nlay) and three sub functions: 1. to select the two text items 2. to copy, explode etc any mtext 3. to delete any spurious punctuation (this replaces the vl-string-translate) Item 2 above copies the mtext in place, explodes it and constructs a single string from the exploded items. These exploded items are then deleted leaving the original mtext. The main function now contains a local error function, and i have also implimented undo marks so that a single undo command will step back to the pre lisp state. Any problems or changes, let me know. NLAY.LSP NLAY-test.dwg Quote Link to comment Share on other sites More sharing options...
kddsuq2727 Posted September 26, 2018 Author Share Posted September 26, 2018 Wow, that works great Thanks 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.