Watson Posted April 21, 2009 Share Posted April 21, 2009 Hello, The Project Managers in my company are running AutoCAD LT 2009. Our company uses a generic project template with the following fields: 01AREA 1 01REP 1 01DEALER 1 01BY 1 01DATE 1 01PM 1 01DWG 1 We use the “FIND” command to replace the generic info with the project specifics, for example, we would FIND “01DATE 1” and replace that with “4/20/09”. This can be a bit tedious, so what I would like is a script to cut down on some of the clicks. Ideally it would run so that the first field would pop up, I’d fill in the appropriate info in the command line then hit the space bar, the next field would pop up, etc, etc… I’ve been looking into this ever since we went to 2009 and have been unable to work something out. PLEASE KEEP IN MIND I AM RUNNING LT. If anyone has a way to do this please let me know. Thanks. Quote Link to comment Share on other sites More sharing options...
Hardeight Posted April 21, 2009 Share Posted April 21, 2009 I don't think it's possible to run the "find" command in the command line only. Which would be what you would really need if you were using it in a script. Plus, and I am no script expert, but I don't believe you would have a way to input information while it is running. This could easily be written in Lisp, but I know the pains you are going through with running LT. You would save yourself a lot of headaches and time by looking into an LT extender of some sort. Quote Link to comment Share on other sites More sharing options...
Watson Posted April 21, 2009 Author Share Posted April 21, 2009 I don't think it's possible to run the "find" command in the command line only. Which would be what you would really need if you were using it in a script. Plus, and I am no script expert, but I don't believe you would have a way to input information while it is running. This could easily be written in Lisp, but I know the pains you are going through with running LT. You would save yourself a lot of headaches and time by looking into an LT extender of some sort. That's what I was afraid of... we've been scratching our heads trying to find a work around. Hmmm.... "LT extender", eh? Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 21, 2009 Share Posted April 21, 2009 A quick Find and Replace LISP - only written on the fly (case-sensitive): (defun c:fnr (/ tStr ss) (while (or (eq "" (setq tStr (getstring t "\nSpecify Text to Search For: "))) (not (setq ss (ssget "X" (list (cons 0 "*TEXT") (cons 1 tStr))))) (eq "" (setq rStr (getstring t "\nSpecify Replacement Text: ")))) (princ "\n<!> No Text Specified or Nothing Found <!>")) (foreach eLst (mapcar 'entget (mapcar 'cadr (ssnamex ss))) (entmod (subst (cons 1 rStr) (assoc 1 eLst) eLst))) (princ)) Quote Link to comment Share on other sites More sharing options...
Watson Posted April 21, 2009 Author Share Posted April 21, 2009 A quick Find and Replace LISP - only written on the fly (case-sensitive): (defun c:fnr (/ tStr ss) (while (or (eq "" (setq tStr (getstring t "\nSpecify Text to Search For: "))) (not (setq ss (ssget "X" (list (cons 0 "*TEXT") (cons 1 tStr))))) (eq "" (setq rStr (getstring t "\nSpecify Replacement Text: ")))) (princ "\n<!> No Text Specified or Nothing Found <!>")) (foreach eLst (mapcar 'entget (mapcar 'cadr (ssnamex ss))) (entmod (subst (cons 1 rStr) (assoc 1 eLst) eLst))) (princ)) Ahhhh... if only I could run LISP Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 21, 2009 Share Posted April 21, 2009 Ahhhh... if only I could run LISP LT is so annoying I agree.. Quote Link to comment Share on other sites More sharing options...
Watson Posted April 21, 2009 Author Share Posted April 21, 2009 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 22, 2009 Share Posted April 22, 2009 I tried via the forum here a while ago to use Autocads find and replace passing it the variables but to no avail. The reason being that Autocad find&replace searches everywhere blocks text mtext etc Re Lt extenders they work well I would questions the price v's say Intellicad which has lisp and VBA ready to go. I believe LT should have lisp in it out of the box. Quote Link to comment Share on other sites More sharing options...
Watson Posted April 22, 2009 Author Share Posted April 22, 2009 Okay, I give up. So a "Find and Replace" script won't work... how about something to do with -ATTEDIT? How would I go about writing a script so the the fields from the OP would show up as defineable on the command line? Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 What am I doing wrong here? Command: -ATTEDIT Edit attributes one at a time? [Yes/No] <Y>: N Performing global editing of attribute values. Edit only attributes visible on screen? [Yes/No] <Y>: N Drawing must be regenerated afterwards. Enter block name specification <*>: A$C49561ED3 Enter attribute tag specification <*>: AAAA Enter attribute value specification <*>: 01AREA 1 1 attributes selected. Enter string to change: 01AREA 1 Enter new string: \ Command: -ATTEDIT Edit attributes one at a time? [Yes/No] <Y>: N Performing global editing of attribute values. Edit only attributes visible on screen? [Yes/No] <Y>: N Drawing must be regenerated afterwards. Enter block name specification <*>: A$C49561ED3 Enter attribute tag specification <*>: AAAA Enter attribute value specification <*>: 01REP 1 1 attributes selected. Enter string to change: 01REP 1 Enter new string: \ Instead of pausing where I have "\", it is naming my string "\". I want that field to be user definable. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 23, 2009 Share Posted April 23, 2009 Are you using some kind of macro like this? ^C^C-attedit;n;n;A$C49561ED3;AAAA;01AREA 1;01AREA 1;\ Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 I'm actually testing it in an .SCR file, but yes that's the gist of it... except I'm trying to have it run to replace multiple attributes (01AREA 1 is the first of seven). The issue is that instead of pausing at the "\", CAD accepts that as the new name of the attribuite. I want it to pause so you can enter the new name, then hit enter and have it move on to the next, etc, etc... Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 This is what it looks like in my .SRC file: -ATTEDIT N N A$C49561ED3 AAAA 01AREA 1 01AREA 1 \ -ATTEDIT N N A$C49561ED3 AAAA 01REP 1 01REP 1 \ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 23, 2009 Share Posted April 23, 2009 Hmm, pausing within a script... not sure I've ever come across doing that Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 So you think it's only possible in macros and not a script? That would explain a lot. Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 BTW, I'm a Project Manager, not a CAD Specialist, so if it sounds like I have no idea what I'm doing, well... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 23, 2009 Share Posted April 23, 2009 Have a read of this: http://www.augi.com/publications/hotnews.asp?page=403 Take particular note to the advantages and disadvantages sections Quote Link to comment Share on other sites More sharing options...
Watson Posted April 23, 2009 Author Share Posted April 23, 2009 I had read that at some point, but obviously not as closely as I should have Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 23, 2009 Share Posted April 23, 2009 No probs - In my opinion, if you are doing this kind of repetitive task on a regular basis, the amount of money you spend on this task from day to day may well outweight the cost of full-blown AutoCAD or even an LT Extender. Just a thought. :wink: Quote Link to comment Share on other sites More sharing options...
Freerefill Posted April 23, 2009 Share Posted April 23, 2009 A little convoluted, but hear me out. .bat file. Before I found a way to do it entirely using a script, I initially had LISP which created a .bat file and a .scr file. The .bat file would open a new instance of AutoCAD, opening a certain .dwg with it, and automatically run the .scr that was created. Script files cannot accept user input. LT means no LISP, which means (getstring) is out. .bat files DO allow user input, and can write to a file. Perhaps a .bat file that creates a script using user input, then runs it in a selected .dwg? I'm working on it now, but I have very little experience with .bat files. *EDIT* Ok, some quick googling turned up some results. Open a new text file (notepad, nothing but) and copy and paste this code. Save it as "something.bat", make SURE the filetype is set to "all files." @echo off set /p input1=Enter input echo -ATTEDIT N N A$C49561ED3 AAAA 01AREA 1 01AREA 1 %input1% > C:\SCRIPTY.SCR After you save it, double-click on it. A command prompt should pop up asking you for input. Enter whatever you like, and end it by hitting "Enter." A new file will be created in your C:\ directory called "SCRIPTY.SCR". So you've just created a script file with prompts for user input, at least one line. You should be able to write multiple lines and return characters. Now, there is a way to open a .dwg and run a script file, but I think you want it to run in the drawing you have open. I'm not sure how to do that, but this is 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.