Author Topic: Layoutspace and Printing, some inspiration and some questions  (Read 1256 times)

0 Members and 1 Guest are viewing this topic.

Blikkie

  • Guest
Layoutspace and Printing, some inspiration and some questions
« on: August 03, 2006, 07:45:43 AM »
Hello,

I have been working for some engineering firm to update their in-house VBA tools to the demands of the modern days. Most of the changes I have implemented work now, but since I am relatively new at programming VBA I'd like to know if my choices were sensible. I think my boss will frown upon fully divulging all the code I have written (and functions have Dutch names and Dutch comments, so they wouldn't be of much use to you anyway), but the global set-up may prove interesting, or completely wrong, but that is up to you to decide.

The old version of the in-house tool just applied borders and scaling to modelspace. In the days of R14 that may have been the way to do things, but nowadays that is what layouts are for.

The first thing i did was programming a menu that offered a limited choice in paper sizes, scales, and border styles, which are all read out of a config file. It set up a pviewport that fits into the border, even if the engineer decides not to use borders for a layout it is still a pretty nice way to define margins. The paper is set up with a custom pc3 file that we can redistribute with our customized installer, that is chosen because it was speedy. The paper sizes for that driver are without margins, since they are a pain to set up.

For printing there was a custom routine in place as well (mostly because older versions of autocad didn't offer lineweight scaling and because they have a nifty extension that helps with multi-file-plotting. They requested that I left it there, so I did. On initializing of the printerform it checks if the active layout has a papersize that is compatible with one of the configured printers. Before printing the layoutsettings are saved, because all the settings may be changed when printing to "fit". They are restored on exiting the dialogue. This is all nice, and working pretty nicely, apart from the fact that restoration only works if I don't exit the dialogue too fast, or else I get stuch with the printer settings that are installed on my system instead of those from my carefully pampered PC3 file.

Do you guys know of any way to detect that the plotter has done it's job, and use that to trigger a RestoreLayout routine? Also feel free to point out any bad ideas now, so I can avoid them in the future.

hendie

  • Guest
Re: Layoutspace and Printing, some inspiration and some questions
« Reply #1 on: August 03, 2006, 07:58:32 AM »
you could use the ENDPLOT event.
in the VBA ide, look at the THISDRAWING module. Select ACADDOCUMENT in the drop down list on the left and in the right drop down, you will have a list of all the events that you have access to

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Layoutspace and Printing, some inspiration and some questions
« Reply #2 on: August 03, 2006, 09:27:41 AM »
I have briefly looked at printer api's but have never messed with them, http://support.microsoft.com/kb/q282474/ seems to have them all there

Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, pDevModeOutput As DEVMODE, pDevModeInput As DEVMODE, ByVal fMode As Long) As Long

Blikkie

  • Guest
Re: Layoutspace and Printing, some inspiration and some questions
« Reply #3 on: August 04, 2006, 05:10:20 AM »
On a related, but completely different note: It almost works now, except for the fact that PlotToFile just takes rediculously long (say >30 secs) while, if I just plot to file from the (original) plot dialog, it works almost instantly. Does anybody have a clue why that might be the case?

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Layoutspace and Printing, some inspiration and some questions
« Reply #4 on: August 04, 2006, 09:51:54 AM »
is it printing in the background?  Can you post your code?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Blikkie

  • Guest
Re: Layoutspace and Printing, some inspiration and some questions
« Reply #5 on: August 04, 2006, 11:14:05 AM »
It is printing in the background, I have made a testproject to be sure and even then my testcode
Code: [Select]
Sub test()
    ThisDrawing.Plot.PlotToFile "c:\test2.plt", ThisDrawing.ActiveLayout.ConfigName
End Sub

takes ages to run, while the printer runs it no problemo.
It's hardly like this code is complicated or anything.