Hello all,
I have already posted about this problem in a different thread, but that one seems to have died out, so I will try to clarify my issue here, and hopefully somebody can run my code and duplicate my problem and help me find out what I'm doing wrong.
Inventor.ApprenticeServerComponent oApprentice = new ApprenticeServerComponent(); Inventor.ApprenticeServerDrawingDocument drgDoc; string idwName = null; OpenFileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { idwName = dlg.FileName; } oApprentice.Open(idwName); drgDoc = (Inventor.ApprenticeServerDrawingDocument)oApprentice.Document; Inventor.ApprenticeDrawingPrintManager pMgr; pMgr = (Inventor.ApprenticeDrawingPrintManager)drgDoc.PrintManager; pMgr.Printer = "HP LaserJet P2015 PCL6"; pMgr.SetSheetRange(1, 1); pMgr.PrintRange = PrintRangeEnum.kPrintSheetRange; pMgr.ScaleMode = Inventor.PrintScaleModeEnum.kPrintBestFitScale; pMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation; pMgr.SubmitPrint();
I have this code executing every time the user clicks a button on my main form. The first time the user clicks the button and selects an idw file, the code runs as expected, and the first drawing sheet of the selected idw is printed.
However, the second time the user selects an idw to print, the program crashes. The wierd part is that if the same idw is selected the second time as the first time, the crash doesn't occur, it's only when a different idw is selected the second time.
My first thought was that either the oApprentice or the drgDoc objects need to be closed, but if I try to close either of these objects at the end of my code, the program crashes as well.
I should mention as well, that this code ran fine under 2012, but when we upgraded to 2013 is when this issue started. Any help would be greatly appreciated.
Lorne
I pasted your code into a new project with the only change being the name of the printer and I can print multiple drawings without any problems. Can you send me a small project and some drawings that demonstrate the problem? You can send them to brian.ekins@autodesk.com. Thanks.
Here are the project files. There seems to be a file size limit so I"ll post the idws separately
Here are the idw files.
I'm able to reproduce it with your drawings. I've filed a change request so it can be investigated.
Thanks for checking this out Brian. How do these requests normally work? Will the defect be fixed in the next release I assume? I am trying to decide what route to take in the meantime until this happens. Maybe you could recommend a better way to do what I’m doing here.
One of the things our plug-in does is allow us to open an Inventor assembly directly from the vault explorer on a workstation that does not have Inventor. From this screen we can easily print all the drawings linked to this assembly. Our designers create most of their idws as multiple page drawing sets. The nice part about this plug-in is it lets you quickly pick out a particular drawing from a large drawing set without paging through the whole drawing set. However the only way I could accomplish this was to actually print (via Apprentice) the selected sheet of the idw. The preview you see in the screenshot is actually a snapshot of the drawing sheet printed to an XPS format file via the Autodesk DWF printer driver called with Apprentice function calls.
While this did work fine in 2012, I realize that it is a pretty complicated way to accomplish the task. Maybe you would know of a simpler way to pick a certain drawing sheet out of a multi-page idw and work around the ‘bug’ in 2013?
There is something else you can use. Actually two different things. The first is a viewer control and the second is some Apprentice functionality referred to as "client views". Internally, the viewer control uses client views anyway. You'll write a little more code if you use client views directly but you'll have more control over the result and you don't have to deal with an extra component. There is a section in the API help about client views that hopefully is enough to get you going.
That's good to know about those options. I had played around a bit with the viewer control sample a bit and couldn't get it to work right but I might look into it again. Also the documentation that came with the InventorView SDK seems to be missing the help file. Can this be downloaded from somewhere?