adc111 Posted May 28, 2012 Share Posted May 28, 2012 I am running a script to process many drawings, and the script ends after the first drawing. I have tracked down the issue but do not know how to work around it: (c:test1 "10.DWG") _.open "10.DWG" (c:test2) _.qsave _.close (c:test1 "11.DWG") _.open "11.DWG" (c:test2) _.qsave _.close ... The problem seems to be trying to issue any command other than "open" after the initial drawing is loaded and closed. If I remove the "(c:test1)" from all lines after the 1st line, then it works fine. The details of test1 don't really matter, I've tried using a built-in AutoCAD command instead and the same problem happens. It's as if AutoCAD won't process any more script commands unless you immediately open another drawing after closing the previous one, in case the script closed the last drawing and there are no more open drawings to execute commands against. But that is not the case, Drawing1.dwg remains open the whole time. Since Drawing1.dwg remains open the whole time, I thought if I could find a command to "activate" or make it "current" again, then perhaps I could issue the test1 command prior to opening the next drawing, something like: activate "Drawing.dwg" (c:test1 "11.DWG") _.open "11.DWG" (c:test2) _.qsave _.close However, I've researched and cannot find any such "activate" command. FYI - I need to run the test1 function on the filename prior to opening the drawing. Any ideas on how to resolve this would be greatly appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 28, 2012 Share Posted May 28, 2012 When you open another dwg you transfer control to that dwg now so any new programs are run on that dwg and ignore prior dwg you would need to do some sort of change back to drawing1 if you want to do something in that dwg and bring it into the next dwg. What is C:test1&2 doing ? Quote Link to comment Share on other sites More sharing options...
adc111 Posted May 28, 2012 Author Share Posted May 28, 2012 Thanks for the reply. So I hope there is a way and someone can help with how to transfer control back to Drawing1 after closing a drawing. Test1 is doing some processing with a remote database using the filename, so it only needs the drawing filename, does not need the drawing open. Test2 is doing standard stuff on the drawing (turn layers on/off, etc.). The details of the functions don't seem to matter, same issue happens if I remove test2 and replace test1 with some standard AutoCAD command. Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 28, 2012 Share Posted May 28, 2012 Then how about doing the processing in two steps: (1) run a script in an empty drawing to perform the said database validation and (2) after run the processing script on the entire bunch? Quote Link to comment Share on other sites More sharing options...
adc111 Posted May 28, 2012 Author Share Posted May 28, 2012 I had thought about that and it is my plan B, but would be preferable to get it working in one step if possible, so that each drawing can be dispatched to a different business process without having to wait for the first step, which will take a long time (thousands of drawings). If it's just a simple matter of a command I need to insert (or something) to transfer control to Drawing1.dwg, then I would go that route. Thanks. Quote Link to comment Share on other sites More sharing options...
miff Posted July 2, 2012 Share Posted July 2, 2012 Is there any reason you are not using scriptpro or autoscript? Quote Link to comment Share on other sites More sharing options...
dbroada Posted July 2, 2012 Share Posted July 2, 2012 without reading everything you have done I run my scripts in SDI mode and finish with qsave open <drawing name> 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.