Lisp + Script + Multiple dwgs in MDI mode.

Lisp + Script + Multiple dwgs in MDI mode.

mdhutchinson
Advisor Advisor
1,004 Views
5 Replies
Message 1 of 6

Lisp + Script + Multiple dwgs in MDI mode.

mdhutchinson
Advisor
Advisor

Now I know I probably could modify my approach to a benchmark tool I've used over the last, well... 8 years now. But I really would rather not. In this benchmark tool I wish to load Trimble PipeDesigner3d as it is very much apart of our workflow.

 

The benchmark tool runs through, nearly to completion uninterrupted and without user involvement opening 5 drawings in (the default) MDI mode, in each, the script is running none stop and continues even as each of the drawings is opened. As each drawing is opened a SaveAs to another name is scripted. After the SaveAs, in each drawing, the script xrefs in 6-8 drawing files and perform a number of automated commands along the way. (At the end of each 'group' of commands I capture the time since the previous 'group' of commands and report it to a csv file.)

 

At the end, after roughly 40+or- minutes each drawing that was previously saved before moving to the next drawing is closed. Normal expected AutoCAD behavior would ordinarily be that you could proceed to close the drawing without AutoCAD thinking that the drawing changed in some way. However, AutoCAD asks if you want to save the changes. Indeed, there are no changes, however, Trimble PipeDesigner for some reason imposes some kind of edit on the drawing so that now it asks if you want to save changes.

 

Now, as I said... I probably could modify the approach to set SDI = 1 and run the benchmark in Single Document Mode... but I would rather not. Yes, at the end of the script to close the drawings and shut down AutoCAD automatically I run the 'QUIT' command. This is what closes all the drawings... but I believe that since PipeDesigner edits the drawing in some way, it asks if you want the drawing saved... 

 

Now the Script that seems to move on just fine in MDI going forward... has no action in each of the drawings as they, one by one now have the focus, but close (by virtue of the 'QUIT' command. 

 

I trust I've explained this well enough to show what is being done.

 

I am wondering if anyone has a thought as to how I might impose one last save on each drawing as it gains focus on its way to being closed. I know I could do 'SAVEALL' command and that should be enough to save any change, but as soon as the next drawing gains focus just after the previous drawing is closed, PipeDesigner want to impose an edit on the drawing.

 

Thoughts?  (.NET I presume... however this is not an option at the moment due to the learning curve and time to learn)

 

Been doing lisp and scripts for quite some time now.

 

0 Likes
1,005 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor

I once had a project to perform 23 operations on 13,000 drawings scattered throughout the branches of one directory.  It ran from one session of AutoCAD on one PC, and used only AutoLisp/Visual Lisp in SDI=0.  I just looked at it and it's quite complex because I wanted to capture, identify, and report any and every error that I could expect.  Except that it ran perfectly with no errors.

 

I would love to share it with you except that it's really my client's intellectual property.  It was 13 years ago and I doubt my contact is still working there, but would you like me to ask permission to share it?

 

I can tell you this much... It used acaddoc.lsp and vl-bb-set and vl-bb-ref to load the LSP (actually VLX) file and maintain the status of every drawing opened.

 

In your case maybe all you need is to check (getvar "dbmod") to see if PipeDesigner requires a save.

John F. Uhden

0 Likes
Message 3 of 6

Anonymous
Not applicable

Check out this post

This runs a shell of AutoCAD, so it is extremely fast.

At the end of the script you can't quit instead of save.

0 Likes
Message 4 of 6

mdhutchinson
Advisor
Advisor

Thanks for the reply... 

I am also using acaddoc.lsp to load the necessary lisp when the drawing is first opened. Also using vl-bb-set and vl-bb-ref.

The blackboard space i am using only to save the various time stamps across the 5 drawings.

SDI=0 and each of the 5 drawings remains open until the series of time stamps are recorded to a CSV file. 

 

I am using QUIT as the very last call in the SCR to get the drawings and AutodCAD to close. 

I believe I had found that the script essentially stops and cannot continue when the focus returns to a drawing.

Acaddoc.lsp I believe only loads on drawing open, and not on focus returning back to the drawing.

 

Perhaps I need to change the end of the script, or perhaps Acaddoc.lsp loads again on focus returning to the drawing.

 

Is it the case that:

  • a script can continue
  • or that Acaddoc.lsp loads a second time...

...on focus returning back to the drawing?

 

If I can test that 'dbmod' changes (or dbpop - forgotten exactly what the call is to trap the dbmod variable from getting modified or that save is needed. perhaps that is what I need.

0 Likes
Message 5 of 6

mdhutchinson
Advisor
Advisor

Yep... I am familiar with CoreConsole and have authored a couple very small experiments with it.

With the purpose to benchmark computers... CoreConsole does not apply. (I've heard it referred to as 'headless' AutoCAD.)

0 Likes
Message 6 of 6

john.uhden
Mentor
Mentor

I know that mine worked on only one drawing at a time with acaddoc.lsp defining an S::STARTUP function to initiate the processes and then saving and closing at which point focus was returned to the original drawing which checked to be sure that there were no other documents open before opening the next.  I see that I did use acad-push-dbmod and acad-pop-dbmod for some reason.  I think it was just to suppress AutoCAD from treating a few setvars (like cmddia) as changes to the drawing database.  Yes, my running error report wrote the failures and processing time to a file for every drawing opened, with a total time upon completion.  I also noticed that it created a new profile which eliminated the loading of other unwanted applications (Land Desktop at the time).

 

I don't think acaddoc.lsp reloads on returning to a drawing.  I apparently made a separate setup.lsp file which contains

 

(foreach file files
  (do_all_you want_to_file file)
  (write_to_report)
  (etc.)
)

which tells me that the original drawing and its namespace picks up right where it left off when the active drawing is closed and focus returns.

John F. Uhden

0 Likes