FatRobo Posted October 20, 2010 Share Posted October 20, 2010 I have been asked to do up a script to tidy up some of our 12d outputs. I want to investigate weather it is worth looking into using lisp. Unfortunately I only have very basic skills in Autolisp. It would be good to take an example to the boss which I could then get approval to spend some more time learning autolisp. In the attached file I need to move some blocks on some layers and some on others. I need to filter out the radius text to put on its own layer and filter out the CTP text and put them on their own layer. I may also need to create a few layers to. If someone could show me this code with any of the layers in there I am sure I could then modify it as I need to. Thanks in advance for the help. Chris. x_droa_MCD0_txt.dwg Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 20, 2010 Share Posted October 20, 2010 Please be more specific... What blocks go on what layer? Radius & CTP Text, on what layers respectively? When specifying a layer, does the layer already exist, or does it need to be created? If being created, what properties should it have (color, description, etc.) Quote Link to comment Share on other sites More sharing options...
FatRobo Posted October 20, 2010 Author Share Posted October 20, 2010 I don't really mind what layer they go on. I was thinking I can modify that as needed or as I am directed by the boss. I was just interested in seeing the code used to do the work. The layers will need to be created. Radius and bearing text can go MR_TXT_025 colour 7, CTP text can go on MR_TXT_050_TP colour 3. All the blocks can go on layer MR_CON_035 colour 2. Thanks for you help so far! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 21, 2010 Share Posted October 21, 2010 You can create a slection set SSget which will filter out say all text via a selction window then you can go through the text look at say its first character "R" and change its layer using a COND any text 0-9 will go on another layer. (cond (= textval "R") (put on layer 1) (= texval "CTP")(put on layer 2) (0-9 put on layer 3) Some one may have some code close to this search for "replace text" Quote Link to comment Share on other sites More sharing options...
FatRobo Posted October 22, 2010 Author Share Posted October 22, 2010 OK so I manage to come up with a compromise and use a script to do the job. However another problem still exists. We used to have 12d output the chainages on diferent layers reprenting different scales. Each of the different scales had the text sitting at a different offset from the control line becuase at a different scale the viewport will be zoomed in more. The 12d guys have to do a lot of work to set that up so apparently they want to stop doing that, but I think it will be more work for the CADies to do it everytime we get a new output. How would you do it in a lisp? I was thinking about it... once the text is selected and copied to another layer each text object would then need to be moved based on its degree of rotation (to keep each bit each chainage pointing at its chainage tick) and a user input of left or right (as the chainages could be sitting on left or right side). Does this make sense? I don't know anything about the code but it doesn't sound very complex. Any idea's? I have attached a file showing how I'd like one of the chainages to look. You can see the different sizes of text have been copied. Cheers. x_droa_MCD0_txt.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2010 Share Posted October 22, 2010 (edited) If 12d have written the text as justification middle left then its pretty easy, checked dwg, the text is at an angle all you need to do is move the text a known amount along this angle. It will be pretty easy to work out the distance for a different height text. 1 ask for new text height 2 get text insertion pt and angle 3 calculate new txt pt and copy txt to it change layer etc 4 change text ht & layer etc 5 repeat steps 2-4 Ps checked dwg your text is moving away from original text location compared to ch marker. Heres a dump of the text using (setq a (entget (entlast))) with the relevant values shown (10 37901.7 152322.0 0.0) insertion pt (50 . 5.08003) roatation angle in radians In lisp (setq ang (assoc 50 a)) and (setq txtpt (assoc 10 a)) then (setq newpt (polar txtpt somedistance ang)) and so on . Will have a look for something that can be hacked to help you others may beat me. Maybe for others pick pick pick pick text changes a bit easier than picking all text in one go ? Edited October 22, 2010 by BIGAL pick pick pick Quote Link to comment Share on other sites More sharing options...
FatRobo Posted October 22, 2010 Author Share Posted October 22, 2010 I understand you process but unfortunately I don't understand the coding. Will look foward to anything you get rough up for me. Cheers, Chris. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 25, 2010 Share Posted October 25, 2010 Something like this not tested. (setvar "osmode" 0) (setq somedistance (getreal "\nEnter offset distance")) ;(while (setq en (entsel "\nPick text")) (setq a (entget (car en))) (setq ang (cdr (assoc 50 a))) ; angle (setq txtpt (cdr(assoc 10 a))) ; insert pt (setq txtht (cdr (assoc 40 a))) ; text ht (setq acttext (cdr (assoc 1 a))) ; text content (setq newpt (polar txtpt somedistance ang)) (command "Text" newpt txtht ang acttext "") ) ;end while You need to add a while so you can keep picking text Quote Link to comment Share on other sites More sharing options...
FatRobo Posted November 1, 2010 Author Share Posted November 1, 2010 Is it possible thats it just does it to a select bunch of text? Rather than picking individual bits of text. so you would select them all once and it copies them all onto preset layers for their different scales. Idealy we need to do text at high 5mm moving at the same direction to its rotation and text and 2.5mm moving perpendicular to its direction. P.S. Can you write the code so that i can put it into a lsp file straight up as I can't seem to figure some fo the sytax when trying to test it. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted November 1, 2010 Share Posted November 1, 2010 P.S. Can you write the code so that i can put it into a lsp file straight up as I can't seem to figure some fo the sytax when trying to test it. No... But, if you post your code, we might be able to better help you. :wink: Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 2, 2010 Share Posted November 2, 2010 Here is a bit more (setvar "osmode" 0) (setq somedistance (getreal "\nEnter offset distance")) (setq en (entsel "\nPick text")) (while (/= en nil) (setq a (entget (car en))) (setq ang (cdr (assoc 50 a))) ; angle (setq txtpt (cdr(assoc 10 a))) ; insert pt (setq txtht (cdr (assoc 40 a))) ; text ht (setq acttext (cdr (assoc 1 a))) ; text content (setq newpt (polar txtpt somedistance ang)) (command "Text" newpt txtht ang acttext ) (setq en (entsel "\nPick text")) ) ;end whilextht just copy and paste the code into notepad and save as a lisp file, it still needs some debugging and will only work with plain text styles not preset height etc. But its a start. 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.