Printing with form

Printing with form

FeelGoodGirl
Advocate Advocate
656件の閲覧回数
6件の返信
メッセージ1/7

Printing with form

FeelGoodGirl
Advocate
Advocate

Hey,

 

I asked a number of questions last week to make my code shorter:

https://forums.autodesk.com/t5/inventor-forum/printing-selected-pages-with-ilogic-how-to-clean-the-c...

This has succeeded, but now a number of other challenges have arisen. That's why this new forum.

 

Broadly speaking, the code works. Only that shows strange behavior in combination with a form.

 

I have made 3 parameters. I can set this to true / false in the form. If the check mark is on, they will be printed and if the check mark is off they will not be printed. In the image below, only Sheet 2 would now be printed.

printing form.png

The idea is that you can first check/uncheck which pages you want. By then pressing the 'Printing' button, printing the desired pages. The best thing would then be that the form box closes. Behind the 'Printing' button I have the following behavior: On Click Action - Apply and then Run Rule.

 

The code used behind the 'Printing' button is:

Dim oDrgDoc As DrawingDocument
Dim oDrgPrintMgr As DrawingPrintManager

oDrgDoc = ThisApplication.ActiveDocument
oDrgPrintMgr = oDrgDoc.PrintManager

' Provide the good status to the page
ThisDoc.Document.Sheets.Item("Sheet1:1").ExcludeFromPrinting = Not(Sheet1)
ThisDoc.Document.Sheets.Item("Sheet2:2").ExcludeFromPrinting = Not(Sheet2)
ThisDoc.Document.Sheets.Item("Sheet3:3").ExcludeFromPrinting = Not(Sheet3)

'--------Printing--------
'Printer name
oDrgPrintMgr.Printer = "Microsoft Print to PDF"
oDrgPrintMgr.SetSheetRange(1,3)

'Paper size, scale and orientation
oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSize11x17
oDrgPrintMgr.PrintRange = PrintRangeEnum.kPrintSheetRange
oDrgPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrgPrintMgr.SubmitPrint()

I can now check/uncheck which pages I want. Then I can push the button 'Printing' and save the pdf. If I then press 'save' it saves the file neatly. But then he asks to save it again. If I do that, it will close the PDF printing. But then I have 2 the same files. I don't know why he does this. In addition, I am unable to close the form if I have printed the file as a pfd.

 

Hopefully someone can help me with this. Thanks in advance.

0 件のいいね
解決済み
657件の閲覧回数
6件の返信
返信 (6)
メッセージ2/7

Anonymous
適用対象外

You can change the button action to "close and run rule" or "apply, close, run rule"-have you tried either of these? I'm guessing the multiple save is coming about because of the changes made to the document. I have a very similar code (looks the same at first glance)for printing and do not have this issue, so I am thinking it is not the code. When it doesn't let you close the form is there any other behavior that goes on? Hidden print dialog somewhere?

-Chancellor

0 件のいいね
メッセージ3/7

FeelGoodGirl
Advocate
Advocate

Hey Chancellor,

 

I have tried the different Behavior options. This is the result:

 

Run Rule: If I check or uncheck a page box, the rule starts running immediately. I first want to be able to make my choices about which pages I will print, and then print.

 

Close and then Run Rule: If I check or uncheck a page box, the rule starts running immediately. I first want to be able to make my choices about which pages I will print, and then print.

 

Apply and then Run Rule: Can now make my choice and then have it printed. But now I get 2x the option to save it.

 

Apply and then Close and then Run Rule: Can now make my choice and then have it printed. But now I get 2x the option to save it. But the form does close.

 

I have still the problem that the file asks 2x to save, but then saves 2x the same. I therefore think that it is in the code.

 

0 件のいいね
メッセージ4/7

Anonymous
適用対象外

Try opening the rule, go to the options tab, and check the box that says "Don't run automatically"-your rule is running automatically on any parameter change it sounds like.

Hope this helps!

-Chancellor

0 件のいいね
メッセージ5/7

FeelGoodGirl
Advocate
Advocate

Thank you for your tips.

run.png

I looked there, but the only one that is checked is "Silent operation". I have tried whether there is a difference between whether or not it is checked. But unfortunately without result. It keeps asking twice to save the file.

0 件のいいね
メッセージ6/7

Anonymous
適用対象外
解決済み

You tried running with "silent operation" checked and unchecked or "don't run automatically" checked and unchecked?

メッセージ7/7

FeelGoodGirl
Advocate
Advocate

I tried running with "silent operation" checked and unchecked. 

 

But now I have also tried "don't run automatically". And this works! the rule does indeed secretly run in the background.

 

Thank you!!😁