Jump to content

Processing of multiple drawings - Script ends after first drawing


Recommended Posts

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...