Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Print Document Loop

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
292 Views, 9 Replies

Print Document Loop

For another user I pieced together a quick and dirty way for a user to print
a PDF (just calls the print routine) when the status of an IDW is set to
released. It works fine (print on a save) but for some reason after it
prints to the PDF it try to print again. Loops sometimes once or twice and
sometimes forever. Thsi is the class module that is called by a sub..See
anything that jumps out at you?

BTW you'll have to change the printer manager value to your printer for it
to run..... TIA



Private WithEvents oApplicationEvents As ApplicationEvents

Public Sub connect()
Set oApplicationEvents = ThisApplication.ApplicationEvents
End Sub


Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)

'check to see if this is an IDW, if not then skip the whole macro
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then

'Check if file is set to Released

' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")

' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument

' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets

' Access the value of the "Design Status" Property
Dim StatusValue As Variant
StatusValue =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesig
nStatusDesignTrackingProperties).Value

'If set to Released then print PDF file
If StatusValue = "3" Then

' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

'Set the printer
oPrintMgr.Printer = "5D PDF Creator"

' Set to print in color.
oPrintMgr.ColorMode = kPrintColorPalette

' Set to print two copies.
oPrintMgr.NumberOfCopies = 2

' Set to print using portrait orientation.
oPrintMgr.Orientation = kPortraitOrientation

' Set the paper size.
oPrintMgr.PaperSize = kPaperSize11x17

' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want to
continue?", vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox("Enter name of new printer:", "New Printer")
If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If

' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets

' Set to print full scale.
oPrintMgr.ScaleMode = kPrintBestFitScale

' Submit the print.
oPrintMgr.SubmitPrint

' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1

' Change the paper size to a custom size. The units are in centimeters.
oPrintMgr.PaperSize = kPaperSize11x17

' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)

' Submit the print.
oPrintMgr.SubmitPrint

Else
End If

Else
End If

End Sub

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

Is this user on R6 SP1 (106) or R5.3? If not, setting
PrintManager.Printer could be a dangerous thing as there was a defect
and the printer name would not be properly set. Try setting everything
up with "5D PDF Creator" as the Windows default printer and make sure
that is what Inventor is defaulting to then REM out the line in your
code which is oPrintMgr.Printer = "5D PDF Creator"

(then tell us if that was it)

"Sean Dotson wrote:

>For another user I pieced together a quick and dirty way for a user to print
>a PDF (just calls the print routine) when the status of an IDW is set to
>released. It works fine (print on a save) but for some reason after it
>prints to the PDF it try to print again. Loops sometimes once or twice and
>sometimes forever. Thsi is the class module that is called by a sub..See
>anything that jumps out at you?
>
>BTW you'll have to change the printer manager value to your printer for it
>to run..... TIA
>
>
>
>Private WithEvents oApplicationEvents As ApplicationEvents
>
>Public Sub connect()
> Set oApplicationEvents = ThisApplication.ApplicationEvents
>End Sub
>
>
>Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
>Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
>NameValueMap, HandlingCode As HandlingCodeEnum)
>
>'check to see if this is an IDW, if not then skip the whole macro
>If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
>
>'Check if file is set to Released
>
> ' Declare the Application object
>Dim oApplication As Inventor.Application
>
>' Obtain the Inventor Application object.
>' This assumes Inventor is already running.
>Set oApplication = GetObject(, "Inventor.Application")
>
>' Set a reference to the active document.
>' This assumes a document is open.
>Dim oDoc As Document
>Set oDoc = oApplication.ActiveDocument
>
>' Obtain the PropertySets collection object
>Dim oPropsets As PropertySets
>Set oPropsets = oDoc.PropertySets
>
>' Access the value of the "Design Status" Property
>Dim StatusValue As Variant
>StatusValue =
>oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesig
>nStatusDesignTrackingProperties).Value
>
>'If set to Released then print PDF file
>If StatusValue = "3" Then
>
>' Set a reference to the print manager object of the active document.
> ' This will fail if a drawing document is not active.
> Dim oPrintMgr As DrawingPrintManager
> Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
>
> 'Set the printer
> oPrintMgr.Printer = "5D PDF Creator"
>
> ' Set to print in color.
> oPrintMgr.ColorMode = kPrintColorPalette
>
> ' Set to print two copies.
> oPrintMgr.NumberOfCopies = 2
>
> ' Set to print using portrait orientation.
> oPrintMgr.Orientation = kPortraitOrientation
>
> ' Set the paper size.
> oPrintMgr.PaperSize = kPaperSize11x17
>
> ' Get the name of the printer that will be used.
> If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want to
>continue?", vbYesNo + vbQuestion) = vbNo Then
> ' Change to another printer.
> Dim sPrinterName As String
> sPrinterName = InputBox("Enter name of new printer:", "New Printer")
> If sPrinterName = "" Then
> Exit Sub
> Else
> oPrintMgr.Printer = sPrinterName
> End If
> End If
>
> ' Set to print all sheets.
> oPrintMgr.PrintRange = kPrintAllSheets
>
> ' Set to print full scale.
> oPrintMgr.ScaleMode = kPrintBestFitScale
>
> ' Submit the print.
> oPrintMgr.SubmitPrint
>
> ' Change the number of copies to 1.
> oPrintMgr.NumberOfCopies = 1
>
> ' Change the paper size to a custom size. The units are in centimeters.
> oPrintMgr.PaperSize = kPaperSize11x17
>
> ' Get and set the current sheet range.
> Dim iFromSheet As Long
> Dim iToSheet As Long
> Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
>
> ' Change the print range to print sheets 1 through 2.
> oPrintMgr.PrintRange = kPrintSheetRange
> Call oPrintMgr.SetSheetRange(1, 2)
>
> ' Submit the print.
> oPrintMgr.SubmitPrint
>
>Else
>End If
>
>Else
>End If
>
>End Sub
>
>--
>Sean Dotson, PE
>http://www.sdotson.com
>...sleep is for the weak..
>-----------------------------------------
>
>
>
>
Message 3 of 10
Anonymous
in reply to: Anonymous

It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
the printer specified directly or use the default printer. Doesn't seem to
make a difference as to version.

Was the bug in R6 and fixed in SP1. The particular machine I'm using
doesn't have SP1 loaded yet.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Charles Bliss" wrote in message
news:3DD26096.3020307@cbliss.com...
> Is this user on R6 SP1 (106) or R5.3? If not, setting
> PrintManager.Printer could be a dangerous thing as there was a defect
> and the printer name would not be properly set. Try setting everything
> up with "5D PDF Creator" as the Windows default printer and make sure
> that is what Inventor is defaulting to then REM out the line in your
> code which is oPrintMgr.Printer = "5D PDF Creator"
>
> (then tell us if that was it)
>
> "Sean Dotson wrote:
>
> >For another user I pieced together a quick and dirty way for a user to
print
> >a PDF (just calls the print routine) when the status of an IDW is set to
> >released. It works fine (print on a save) but for some reason after it
> >prints to the PDF it try to print again. Loops sometimes once or twice
and
> >sometimes forever. Thsi is the class module that is called by a sub..See
> >anything that jumps out at you?
> >
> >BTW you'll have to change the printer manager value to your printer for
it
> >to run..... TIA
> >
> >
> >
> >Private WithEvents oApplicationEvents As ApplicationEvents
> >
> >Public Sub connect()
> > Set oApplicationEvents = ThisApplication.ApplicationEvents
> >End Sub
> >
> >
> >Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
> >Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
> >NameValueMap, HandlingCode As HandlingCodeEnum)
> >
> >'check to see if this is an IDW, if not then skip the whole macro
> >If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject T
hen
> >
> >'Check if file is set to Released
> >
> > ' Declare the Application object
> >Dim oApplication As Inventor.Application
> >
> >' Obtain the Inventor Application object.
> >' This assumes Inventor is already running.
> >Set oApplication = GetObject(, "Inventor.Application")
> >
> >' Set a reference to the active document.
> >' This assumes a document is open.
> >Dim oDoc As Document
> >Set oDoc = oApplication.ActiveDocument
> >
> >' Obtain the PropertySets collection object
> >Dim oPropsets As PropertySets
> >Set oPropsets = oDoc.PropertySets
> >
> >' Access the value of the "Design Status" Property
> >Dim StatusValue As Variant
> >StatusValue =
>
>oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
g
> >nStatusDesignTrackingProperties).Value
> >
> >'If set to Released then print PDF file
> >If StatusValue = "3" Then
> >
> >' Set a reference to the print manager object of the active document.
> > ' This will fail if a drawing document is not active.
> > Dim oPrintMgr As DrawingPrintManager
> > Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
> >
> > 'Set the printer
> > oPrintMgr.Printer = "5D PDF Creator"
> >
> > ' Set to print in color.
> > oPrintMgr.ColorMode = kPrintColorPalette
> >
> > ' Set to print two copies.
> > oPrintMgr.NumberOfCopies = 2
> >
> > ' Set to print using portrait orientation.
> > oPrintMgr.Orientation = kPortraitOrientation
> >
> > ' Set the paper size.
> > oPrintMgr.PaperSize = kPaperSize11x17
> >
> > ' Get the name of the printer that will be used.
> > If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want
to
> >continue?", vbYesNo + vbQuestion) = vbNo Then
> > ' Change to another printer.
> > Dim sPrinterName As String
> > sPrinterName = InputBox("Enter name of new printer:", "New
Printer")
> > If sPrinterName = "" Then
> > Exit Sub
> > Else
> > oPrintMgr.Printer = sPrinterName
> > End If
> > End If
> >
> > ' Set to print all sheets.
> > oPrintMgr.PrintRange = kPrintAllSheets
> >
> > ' Set to print full scale.
> > oPrintMgr.ScaleMode = kPrintBestFitScale
> >
> > ' Submit the print.
> > oPrintMgr.SubmitPrint
> >
> > ' Change the number of copies to 1.
> > oPrintMgr.NumberOfCopies = 1
> >
> > ' Change the paper size to a custom size. The units are in
centimeters.
> > oPrintMgr.PaperSize = kPaperSize11x17
> >
> > ' Get and set the current sheet range.
> > Dim iFromSheet As Long
> > Dim iToSheet As Long
> > Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
> >
> > ' Change the print range to print sheets 1 through 2.
> > oPrintMgr.PrintRange = kPrintSheetRange
> > Call oPrintMgr.SetSheetRange(1, 2)
> >
> > ' Submit the print.
> > oPrintMgr.SubmitPrint
> >
> >Else
> >End If
> >
> >Else
> >End If
> >
> >End Sub
> >
> >--
> >Sean Dotson, PE
> >http://www.sdotson.com
> >...sleep is for the weak..
> >-----------------------------------------
> >
> >
> >
> >
>
Message 4 of 10
Anonymous
in reply to: Anonymous

The bug was supposed to be fixed in R6SP1 (106).  I haven't checked it in
106 yet.  This problem did not exist in R5.3 so I suspect your problem is
elsewhere if the user is on R5.3sp2



Sean Dotson wrote:


cite="mid03D6E0B4CB2205E974C3C79089BD4003@in.WebX.maYIadrTaRb">
It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
the printer specified directly or use the default printer. Doesn't seem to
make a difference as to version.

Was the bug in R6 and fixed in SP1. The particular machine I'm using
doesn't have SP1 loaded yet.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Charles Bliss" <cbliss@cbliss.com> wrote in message
news:3DD26096.3020307@cbliss.com...


Is this user on R6 SP1 (106) or R5.3?  If not, setting
PrintManager.Printer could be a dangerous thing as there was a defect
and the printer name would not be properly set. Try setting everything
up with "5D PDF Creator" as the Windows default printer and make sure
that is what Inventor is defaulting to then REM out the line in your
code which is oPrintMgr.Printer = "5D PDF Creator"

(then tell us if that was it)

"Sean Dotson wrote:



For another user I pieced together a quick and dirty way for a user to



print



a PDF (just calls the print routine) when the status of an IDW is set to
released. It works fine (print on a save) but for some reason after it
prints to the PDF it try to print again. Loops sometimes once or twice



and



sometimes forever.  Thsi is the class module that is called by a sub..See
anything that jumps out at you?

BTW you'll have to change the printer manager value to your printer for



it



to run..... TIA



Private WithEvents oApplicationEvents As ApplicationEvents

Public Sub connect()
Set oApplicationEvents = ThisApplication.ApplicationEvents
End Sub


Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)

'check to see if this is an IDW, if not then skip the whole macro
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject T



hen



'Check if file is set to Released

' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")

' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument

' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets

' Access the value of the "Design Status" Property
Dim StatusValue As Variant
StatusValue =


oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi


g



nStatusDesignTrackingProperties).Value

'If set to Released then print PDF file
If StatusValue = "3" Then

' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

'Set the printer
oPrintMgr.Printer = "5D PDF Creator"

' Set to print in color.
oPrintMgr.ColorMode = kPrintColorPalette

' Set to print two copies.
oPrintMgr.NumberOfCopies = 2

' Set to print using portrait orientation.
oPrintMgr.Orientation = kPortraitOrientation

' Set the paper size.
oPrintMgr.PaperSize = kPaperSize11x17

' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want



to



continue?", vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox("Enter name of new printer:", "New



Printer")



       If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If

' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets

' Set to print full scale.
oPrintMgr.ScaleMode = kPrintBestFitScale

' Submit the print.
oPrintMgr.SubmitPrint

' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1

' Change the paper size to a custom size. The units are in



centimeters.



   oPrintMgr.PaperSize = kPaperSize11x17

' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)

' Submit the print.
oPrintMgr.SubmitPrint

Else
End If

Else
End If

End Sub

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------












Message 5 of 10
Anonymous
in reply to: Anonymous

SP1 has been released??

--
Veign
www.veign.com
<> - Bigger, Better, Cleaner!
www.veign.com/download_application.html#Link200
Code Samples & Sample Projects
http://www.veign.com/information/application/info_app.html
Submit Your Best Code (you keep the rights)
http://www.veign.com/information/application/code_submit.html
---------
"Sean Dotson" wrote in message
news:03D6E0B4CB2205E974C3C79089BD4003@in.WebX.maYIadrTaRb...
> It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
> the printer specified directly or use the default printer. Doesn't seem
to
> make a difference as to version.
>
> Was the bug in R6 and fixed in SP1. The particular machine I'm using
> doesn't have SP1 loaded yet.
>
> --
> Sean Dotson, PE
> http://www.sdotson.com
> ...sleep is for the weak..
> -----------------------------------------
> "Charles Bliss" wrote in message
> news:3DD26096.3020307@cbliss.com...
> > Is this user on R6 SP1 (106) or R5.3? If not, setting
> > PrintManager.Printer could be a dangerous thing as there was a defect
> > and the printer name would not be properly set. Try setting everything
> > up with "5D PDF Creator" as the Windows default printer and make sure
> > that is what Inventor is defaulting to then REM out the line in your
> > code which is oPrintMgr.Printer = "5D PDF Creator"
> >
> > (then tell us if that was it)
> >
> > "Sean Dotson wrote:
> >
> > >For another user I pieced together a quick and dirty way for a user to
> print
> > >a PDF (just calls the print routine) when the status of an IDW is set
to
> > >released. It works fine (print on a save) but for some reason after it
> > >prints to the PDF it try to print again. Loops sometimes once or twice
> and
> > >sometimes forever. Thsi is the class module that is called by a
sub..See
> > >anything that jumps out at you?
> > >
> > >BTW you'll have to change the printer manager value to your printer for
> it
> > >to run..... TIA
> > >
> > >
> > >
> > >Private WithEvents oApplicationEvents As ApplicationEvents
> > >
> > >Public Sub connect()
> > > Set oApplicationEvents = ThisApplication.ApplicationEvents
> > >End Sub
> > >
> > >
> > >Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
> > >Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
> > >NameValueMap, HandlingCode As HandlingCodeEnum)
> > >
> > >'check to see if this is an IDW, if not then skip the whole macro
> > >If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject
T
> hen
> > >
> > >'Check if file is set to Released
> > >
> > > ' Declare the Application object
> > >Dim oApplication As Inventor.Application
> > >
> > >' Obtain the Inventor Application object.
> > >' This assumes Inventor is already running.
> > >Set oApplication = GetObject(, "Inventor.Application")
> > >
> > >' Set a reference to the active document.
> > >' This assumes a document is open.
> > >Dim oDoc As Document
> > >Set oDoc = oApplication.ActiveDocument
> > >
> > >' Obtain the PropertySets collection object
> > >Dim oPropsets As PropertySets
> > >Set oPropsets = oDoc.PropertySets
> > >
> > >' Access the value of the "Design Status" Property
> > >Dim StatusValue As Variant
> > >StatusValue =
> >
>
>oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
> g
> > >nStatusDesignTrackingProperties).Value
> > >
> > >'If set to Released then print PDF file
> > >If StatusValue = "3" Then
> > >
> > >' Set a reference to the print manager object of the active document.
> > > ' This will fail if a drawing document is not active.
> > > Dim oPrintMgr As DrawingPrintManager
> > > Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
> > >
> > > 'Set the printer
> > > oPrintMgr.Printer = "5D PDF Creator"
> > >
> > > ' Set to print in color.
> > > oPrintMgr.ColorMode = kPrintColorPalette
> > >
> > > ' Set to print two copies.
> > > oPrintMgr.NumberOfCopies = 2
> > >
> > > ' Set to print using portrait orientation.
> > > oPrintMgr.Orientation = kPortraitOrientation
> > >
> > > ' Set the paper size.
> > > oPrintMgr.PaperSize = kPaperSize11x17
> > >
> > > ' Get the name of the printer that will be used.
> > > If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want
> to
> > >continue?", vbYesNo + vbQuestion) = vbNo Then
> > > ' Change to another printer.
> > > Dim sPrinterName As String
> > > sPrinterName = InputBox("Enter name of new printer:", "New
> Printer")
> > > If sPrinterName = "" Then
> > > Exit Sub
> > > Else
> > > oPrintMgr.Printer = sPrinterName
> > > End If
> > > End If
> > >
> > > ' Set to print all sheets.
> > > oPrintMgr.PrintRange = kPrintAllSheets
> > >
> > > ' Set to print full scale.
> > > oPrintMgr.ScaleMode = kPrintBestFitScale
> > >
> > > ' Submit the print.
> > > oPrintMgr.SubmitPrint
> > >
> > > ' Change the number of copies to 1.
> > > oPrintMgr.NumberOfCopies = 1
> > >
> > > ' Change the paper size to a custom size. The units are in
> centimeters.
> > > oPrintMgr.PaperSize = kPaperSize11x17
> > >
> > > ' Get and set the current sheet range.
> > > Dim iFromSheet As Long
> > > Dim iToSheet As Long
> > > Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
> > >
> > > ' Change the print range to print sheets 1 through 2.
> > > oPrintMgr.PrintRange = kPrintSheetRange
> > > Call oPrintMgr.SetSheetRange(1, 2)
> > >
> > > ' Submit the print.
> > > oPrintMgr.SubmitPrint
> > >
> > >Else
> > >End If
> > >
> > >Else
> > >End If
> > >
> > >End Sub
> > >
> > >--
> > >Sean Dotson, PE
> > >http://www.sdotson.com
> > >...sleep is for the weak..
> > >-----------------------------------------
> > >
> > >
> > >
> > >
> >
>
>
Message 6 of 10
Anonymous
in reply to: Anonymous

for ADN members and other select testers. Public release is scheduled for
Nov 15th to the best of my knowledge.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Veign" wrote in message
news:C8223F272D92BDF6060F88E141609CD7@in.WebX.maYIadrTaRb...
> SP1 has been released??
>
> --
> Veign
> www.veign.com
> <> - Bigger, Better, Cleaner!
> www.veign.com/download_application.html#Link200
> Code Samples & Sample Projects
> http://www.veign.com/information/application/info_app.html
> Submit Your Best Code (you keep the rights)
> http://www.veign.com/information/application/code_submit.html
> ---------
> "Sean Dotson" wrote in message
> news:03D6E0B4CB2205E974C3C79089BD4003@in.WebX.maYIadrTaRb...
> > It loops (usually twice but up to infinity) in both 5.3 and 6 when I
have
> > the printer specified directly or use the default printer. Doesn't seem
> to
> > make a difference as to version.
> >
> > Was the bug in R6 and fixed in SP1. The particular machine I'm using
> > doesn't have SP1 loaded yet.
> >
> > --
> > Sean Dotson, PE
> > http://www.sdotson.com
> > ...sleep is for the weak..
> > -----------------------------------------
> > "Charles Bliss" wrote in message
> > news:3DD26096.3020307@cbliss.com...
> > > Is this user on R6 SP1 (106) or R5.3? If not, setting
> > > PrintManager.Printer could be a dangerous thing as there was a defect
> > > and the printer name would not be properly set. Try setting
everything
> > > up with "5D PDF Creator" as the Windows default printer and make sure
> > > that is what Inventor is defaulting to then REM out the line in your
> > > code which is oPrintMgr.Printer = "5D PDF Creator"
> > >
> > > (then tell us if that was it)
> > >
> > > "Sean Dotson wrote:
> > >
> > > >For another user I pieced together a quick and dirty way for a user
to
> > print
> > > >a PDF (just calls the print routine) when the status of an IDW is set
> to
> > > >released. It works fine (print on a save) but for some reason after
it
> > > >prints to the PDF it try to print again. Loops sometimes once or
twice
> > and
> > > >sometimes forever. Thsi is the class module that is called by a
> sub..See
> > > >anything that jumps out at you?
> > > >
> > > >BTW you'll have to change the printer manager value to your printer
for
> > it
> > > >to run..... TIA
> > > >
> > > >
> > > >
> > > >Private WithEvents oApplicationEvents As ApplicationEvents
> > > >
> > > >Public Sub connect()
> > > > Set oApplicationEvents = ThisApplication.ApplicationEvents
> > > >End Sub
> > > >
> > > >
> > > >Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
> > > >Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
> > > >NameValueMap, HandlingCode As HandlingCodeEnum)
> > > >
> > > >'check to see if this is an IDW, if not then skip the whole macro
> > > >If ThisApplication.ActiveDocument.DocumentType =
kDrawingDocumentObject
> T
> > hen
> > > >
> > > >'Check if file is set to Released
> > > >
> > > > ' Declare the Application object
> > > >Dim oApplication As Inventor.Application
> > > >
> > > >' Obtain the Inventor Application object.
> > > >' This assumes Inventor is already running.
> > > >Set oApplication = GetObject(, "Inventor.Application")
> > > >
> > > >' Set a reference to the active document.
> > > >' This assumes a document is open.
> > > >Dim oDoc As Document
> > > >Set oDoc = oApplication.ActiveDocument
> > > >
> > > >' Obtain the PropertySets collection object
> > > >Dim oPropsets As PropertySets
> > > >Set oPropsets = oDoc.PropertySets
> > > >
> > > >' Access the value of the "Design Status" Property
> > > >Dim StatusValue As Variant
> > > >StatusValue =
> > >
> >
>
>oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
> > g
> > > >nStatusDesignTrackingProperties).Value
> > > >
> > > >'If set to Released then print PDF file
> > > >If StatusValue = "3" Then
> > > >
> > > >' Set a reference to the print manager object of the active document.
> > > > ' This will fail if a drawing document is not active.
> > > > Dim oPrintMgr As DrawingPrintManager
> > > > Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
> > > >
> > > > 'Set the printer
> > > > oPrintMgr.Printer = "5D PDF Creator"
> > > >
> > > > ' Set to print in color.
> > > > oPrintMgr.ColorMode = kPrintColorPalette
> > > >
> > > > ' Set to print two copies.
> > > > oPrintMgr.NumberOfCopies = 2
> > > >
> > > > ' Set to print using portrait orientation.
> > > > oPrintMgr.Orientation = kPortraitOrientation
> > > >
> > > > ' Set the paper size.
> > > > oPrintMgr.PaperSize = kPaperSize11x17
> > > >
> > > > ' Get the name of the printer that will be used.
> > > > If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you
want
> > to
> > > >continue?", vbYesNo + vbQuestion) = vbNo Then
> > > > ' Change to another printer.
> > > > Dim sPrinterName As String
> > > > sPrinterName = InputBox("Enter name of new printer:", "New
> > Printer")
> > > > If sPrinterName = "" Then
> > > > Exit Sub
> > > > Else
> > > > oPrintMgr.Printer = sPrinterName
> > > > End If
> > > > End If
> > > >
> > > > ' Set to print all sheets.
> > > > oPrintMgr.PrintRange = kPrintAllSheets
> > > >
> > > > ' Set to print full scale.
> > > > oPrintMgr.ScaleMode = kPrintBestFitScale
> > > >
> > > > ' Submit the print.
> > > > oPrintMgr.SubmitPrint
> > > >
> > > > ' Change the number of copies to 1.
> > > > oPrintMgr.NumberOfCopies = 1
> > > >
> > > > ' Change the paper size to a custom size. The units are in
> > centimeters.
> > > > oPrintMgr.PaperSize = kPaperSize11x17
> > > >
> > > > ' Get and set the current sheet range.
> > > > Dim iFromSheet As Long
> > > > Dim iToSheet As Long
> > > > Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
> > > >
> > > > ' Change the print range to print sheets 1 through 2.
> > > > oPrintMgr.PrintRange = kPrintSheetRange
> > > > Call oPrintMgr.SetSheetRange(1, 2)
> > > >
> > > > ' Submit the print.
> > > > oPrintMgr.SubmitPrint
> > > >
> > > >Else
> > > >End If
> > > >
> > > >Else
> > > >End If
> > > >
> > > >End Sub
> > > >
> > > >--
> > > >Sean Dotson, PE
> > > >http://www.sdotson.com
> > > >...sleep is for the weak..
> > > >-----------------------------------------
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
>
>
Message 7 of 10
Anonymous
in reply to: Anonymous

D'oh.. just found it...

 

I have two oPrintMgr.SubmitPrint
commands in the code...getting rid of one of them fixes the
problem

 

<bonehead> sorry....

 

but I wonder why i was getting three prints
sometimes?


--
Sean Dotson, PE

href="http://www.sdotson.com">http://www.sdotson.com

...sleep is for the
weak..
-----------------------------------------


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
The
bug was supposed to be fixed in R6SP1 (106).  I haven't checked it in 106
yet.  This problem did not exist in R5.3 so I suspect your problem is
elsewhere if the user is on R5.3sp2

@sean Dotson wrote:


type="cite">
It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
the printer specified directly or use the default printer. Doesn't seem to
make a difference as to version.

Was the bug in R6 and fixed in SP1. The particular machine I'm using
doesn't have SP1 loaded yet.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Charles Bliss" <cbliss@cbliss.com> wrote in message
news:3DD26096.3020307@cbliss.com...

Is this user on R6 SP1 (106) or R5.3?  If not, setting
PrintManager.Printer could be a dangerous thing as there was a defect
and the printer name would not be properly set. Try setting everything
up with "5D PDF Creator" as the Windows default printer and make sure
that is what Inventor is defaulting to then REM out the line in your
code which is oPrintMgr.Printer = "5D PDF Creator"

(then tell us if that was it)

"Sean Dotson wrote:


For another user I pieced together a quick and dirty way for a user to
print


a PDF (just calls the print routine) when the status of an IDW is set to
released. It works fine (print on a save) but for some reason after it
prints to the PDF it try to print again. Loops sometimes once or twice
and


sometimes forever.  Thsi is the class module that is called by a sub..See
anything that jumps out at you?

BTW you'll have to change the printer manager value to your printer for
it


to run..... TIA



Private WithEvents oApplicationEvents As ApplicationEvents

Public Sub connect()
Set oApplicationEvents = ThisApplication.ApplicationEvents
End Sub


Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)

'check to see if this is an IDW, if not then skip the whole macro
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject T
hen


'Check if file is set to Released

' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")

' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument

' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets

' Access the value of the "Design Status" Property
Dim StatusValue As Variant
StatusValue =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
g


nStatusDesignTrackingProperties).Value

'If set to Released then print PDF file
If StatusValue = "3" Then

' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

'Set the printer
oPrintMgr.Printer = "5D PDF Creator"

' Set to print in color.
oPrintMgr.ColorMode = kPrintColorPalette

' Set to print two copies.
oPrintMgr.NumberOfCopies = 2

' Set to print using portrait orientation.
oPrintMgr.Orientation = kPortraitOrientation

' Set the paper size.
oPrintMgr.PaperSize = kPaperSize11x17

' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want
to


continue?", vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox("Enter name of new printer:", "New
Printer")


       If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If

' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets

' Set to print full scale.
oPrintMgr.ScaleMode = kPrintBestFitScale

' Submit the print.
oPrintMgr.SubmitPrint

' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1

' Change the paper size to a custom size. The units are in
centimeters.


   oPrintMgr.PaperSize = kPaperSize11x17

' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)

' Submit the print.
oPrintMgr.SubmitPrint

Else
End If

Else
End If

End Sub

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------







Message 8 of 10
Anonymous
in reply to: Anonymous

I think you also want to add a check at the top of
the function to check the value of the BeforeOrAfter argument.  This event
should get fired twice when a document is saved, once before the save and then
again after.  It wouldn't matter which one you listen for in this case, but
you only want to respond to one of them.

 

-Brian


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

D'oh.. just found it...

 

I have two oPrintMgr.SubmitPrint
commands in the code...getting rid of one of them fixes the
problem

 

<bonehead> sorry....

 

but I wonder why i was getting three prints
sometimes?


--
Sean Dotson, PE

href="http://www.sdotson.com">http://www.sdotson.com

...sleep is for
the weak..
-----------------------------------------


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
The
bug was supposed to be fixed in R6SP1 (106).  I haven't checked it in
106 yet.  This problem did not exist in R5.3 so I suspect your problem
is elsewhere if the user is on R5.3sp2

@sean Dotson wrote:


type="cite">
It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
the printer specified directly or use the default printer. Doesn't seem to
make a difference as to version.

Was the bug in R6 and fixed in SP1. The particular machine I'm using
doesn't have SP1 loaded yet.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Charles Bliss" <cbliss@cbliss.com> wrote in message
news:3DD26096.3020307@cbliss.com...

Is this user on R6 SP1 (106) or R5.3?  If not, setting
PrintManager.Printer could be a dangerous thing as there was a defect
and the printer name would not be properly set. Try setting everything
up with "5D PDF Creator" as the Windows default printer and make sure
that is what Inventor is defaulting to then REM out the line in your
code which is oPrintMgr.Printer = "5D PDF Creator"

(then tell us if that was it)

"Sean Dotson wrote:


For another user I pieced together a quick and dirty way for a user to
print


a PDF (just calls the print routine) when the status of an IDW is set to
released. It works fine (print on a save) but for some reason after it
prints to the PDF it try to print again. Loops sometimes once or twice
and


sometimes forever.  Thsi is the class module that is called by a sub..See
anything that jumps out at you?

BTW you'll have to change the printer manager value to your printer for
it


to run..... TIA



Private WithEvents oApplicationEvents As ApplicationEvents

Public Sub connect()
Set oApplicationEvents = ThisApplication.ApplicationEvents
End Sub


Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)

'check to see if this is an IDW, if not then skip the whole macro
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject T
hen


'Check if file is set to Released

' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")

' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument

' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets

' Access the value of the "Design Status" Property
Dim StatusValue As Variant
StatusValue =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
g


nStatusDesignTrackingProperties).Value

'If set to Released then print PDF file
If StatusValue = "3" Then

' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

'Set the printer
oPrintMgr.Printer = "5D PDF Creator"

' Set to print in color.
oPrintMgr.ColorMode = kPrintColorPalette

' Set to print two copies.
oPrintMgr.NumberOfCopies = 2

' Set to print using portrait orientation.
oPrintMgr.Orientation = kPortraitOrientation

' Set the paper size.
oPrintMgr.PaperSize = kPaperSize11x17

' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want
to


continue?", vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox("Enter name of new printer:", "New
Printer")


       If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If

' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets

' Set to print full scale.
oPrintMgr.ScaleMode = kPrintBestFitScale

' Submit the print.
oPrintMgr.SubmitPrint

' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1

' Change the paper size to a custom size. The units are in
centimeters.


   oPrintMgr.PaperSize = kPaperSize11x17

' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)

' Submit the print.
oPrintMgr.SubmitPrint

Else
End If

Else
End If

End Sub

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------







Message 9 of 10
Anonymous
in reply to: Anonymous

Thanks Brian.

 

Declaring kAfter seemed to stabilize it a bit
more.

 


--
Sean Dotson, PE

href="http://www.sdotson.com">http://www.sdotson.com

...sleep is for the
weak..
-----------------------------------------


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

I think you also want to add a check at the top
of the function to check the value of the BeforeOrAfter argument.  This
event should get fired twice when a document is saved, once before the save
and then again after.  It wouldn't matter which one you listen for in
this case, but you only want to respond to one of them.

 

-Brian


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

D'oh.. just found it...

 

I have two oPrintMgr.SubmitPrint
commands in the code...getting rid of one of them fixes the
problem

 

<bonehead> sorry....

 

but I wonder why i was getting three prints
sometimes?


--
Sean Dotson, PE

href="http://www.sdotson.com">http://www.sdotson.com

...sleep is for
the weak..
-----------------------------------------


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
The
bug was supposed to be fixed in R6SP1 (106).  I haven't checked it in
106 yet.  This problem did not exist in R5.3 so I suspect your
problem is elsewhere if the user is on R5.3sp2

Sean Dotson
@ wrote:


cite="mid03D6E0B4CB2205E974C3C79089BD4003@in.WebX.maYIadrTaRb">
It loops (usually twice but up to infinity) in both 5.3 and 6 when I have
the printer specified directly or use the default printer. Doesn't seem to
make a difference as to version.

Was the bug in R6 and fixed in SP1. The particular machine I'm using
doesn't have SP1 loaded yet.

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------
"Charles Bliss" <cbliss@cbliss.com> wrote in message
news:3DD26096.3020307@cbliss.com...

Is this user on R6 SP1 (106) or R5.3?  If not, setting
PrintManager.Printer could be a dangerous thing as there was a defect
and the printer name would not be properly set. Try setting everything
up with "5D PDF Creator" as the Windows default printer and make sure
that is what Inventor is defaulting to then REM out the line in your
code which is oPrintMgr.Printer = "5D PDF Creator"

(then tell us if that was it)

"Sean Dotson wrote:


For another user I pieced together a quick and dirty way for a user to
print


a PDF (just calls the print routine) when the status of an IDW is set to
released. It works fine (print on a save) but for some reason after it
prints to the PDF it try to print again. Loops sometimes once or twice
and


sometimes forever.  Thsi is the class module that is called by a sub..See
anything that jumps out at you?

BTW you'll have to change the printer manager value to your printer for
it


to run..... TIA



Private WithEvents oApplicationEvents As ApplicationEvents

Public Sub connect()
Set oApplicationEvents = ThisApplication.ApplicationEvents
End Sub


Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)

'check to see if this is an IDW, if not then skip the whole macro
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject T
hen


'Check if file is set to Released

' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")

' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument

' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets

' Access the value of the "Design Status" Property
Dim StatusValue As Variant
StatusValue =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
g


nStatusDesignTrackingProperties).Value

'If set to Released then print PDF file
If StatusValue = "3" Then

' Set a reference to the print manager object of the active document.
' This will fail if a drawing document is not active.
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

'Set the printer
oPrintMgr.Printer = "5D PDF Creator"

' Set to print in color.
oPrintMgr.ColorMode = kPrintColorPalette

' Set to print two copies.
oPrintMgr.NumberOfCopies = 2

' Set to print using portrait orientation.
oPrintMgr.Orientation = kPortraitOrientation

' Set the paper size.
oPrintMgr.PaperSize = kPaperSize11x17

' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you want
to


continue?", vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox("Enter name of new printer:", "New
Printer")


       If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If

' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets

' Set to print full scale.
oPrintMgr.ScaleMode = kPrintBestFitScale

' Submit the print.
oPrintMgr.SubmitPrint

' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1

' Change the paper size to a custom size. The units are in
centimeters.


   oPrintMgr.PaperSize = kPaperSize11x17

' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)

' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)

' Submit the print.
oPrintMgr.SubmitPrint

Else
End If

Else
End If

End Sub

--
Sean Dotson, PE
http://www.sdotson.com
...sleep is for the weak..
-----------------------------------------







Message 10 of 10
Anonymous
in reply to: Anonymous

boo.... thanks Sean!
I'll lurk here as well! I forgot about this group!




"Sean Dotson" wrote in message
news:22B4A0AC2138E1EF1EE907A187713A38@in.WebX.maYIadrTaRb...
> for ADN members and other select testers. Public release is scheduled for
> Nov 15th to the best of my knowledge.
>
> --
> Sean Dotson, PE
> http://www.sdotson.com
> ...sleep is for the weak..
> -----------------------------------------
> "Veign" wrote in message
> news:C8223F272D92BDF6060F88E141609CD7@in.WebX.maYIadrTaRb...
> > SP1 has been released??
> >
> > --
> > Veign
> > www.veign.com
> > <> - Bigger, Better, Cleaner!
> > www.veign.com/download_application.html#Link200
> > Code Samples & Sample Projects
> > http://www.veign.com/information/application/info_app.html
> > Submit Your Best Code (you keep the rights)
> > http://www.veign.com/information/application/code_submit.html
> > ---------
> > "Sean Dotson" wrote in message
> > news:03D6E0B4CB2205E974C3C79089BD4003@in.WebX.maYIadrTaRb...
> > > It loops (usually twice but up to infinity) in both 5.3 and 6 when I
> have
> > > the printer specified directly or use the default printer. Doesn't
seem
> > to
> > > make a difference as to version.
> > >
> > > Was the bug in R6 and fixed in SP1. The particular machine I'm using
> > > doesn't have SP1 loaded yet.
> > >
> > > --
> > > Sean Dotson, PE
> > > http://www.sdotson.com
> > > ...sleep is for the weak..
> > > -----------------------------------------
> > > "Charles Bliss" wrote in message
> > > news:3DD26096.3020307@cbliss.com...
> > > > Is this user on R6 SP1 (106) or R5.3? If not, setting
> > > > PrintManager.Printer could be a dangerous thing as there was a
defect
> > > > and the printer name would not be properly set. Try setting
> everything
> > > > up with "5D PDF Creator" as the Windows default printer and make
sure
> > > > that is what Inventor is defaulting to then REM out the line in your
> > > > code which is oPrintMgr.Printer = "5D PDF Creator"
> > > >
> > > > (then tell us if that was it)
> > > >
> > > > "Sean Dotson wrote:
> > > >
> > > > >For another user I pieced together a quick and dirty way for a user
> to
> > > print
> > > > >a PDF (just calls the print routine) when the status of an IDW is
set
> > to
> > > > >released. It works fine (print on a save) but for some reason
after
> it
> > > > >prints to the PDF it try to print again. Loops sometimes once or
> twice
> > > and
> > > > >sometimes forever. Thsi is the class module that is called by a
> > sub..See
> > > > >anything that jumps out at you?
> > > > >
> > > > >BTW you'll have to change the printer manager value to your printer
> for
> > > it
> > > > >to run..... TIA
> > > > >
> > > > >
> > > > >
> > > > >Private WithEvents oApplicationEvents As ApplicationEvents
> > > > >
> > > > >Public Sub connect()
> > > > > Set oApplicationEvents = ThisApplication.ApplicationEvents
> > > > >End Sub
> > > > >
> > > > >
> > > > >Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject
As
> > > > >Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
> > > > >NameValueMap, HandlingCode As HandlingCodeEnum)
> > > > >
> > > > >'check to see if this is an IDW, if not then skip the whole macro
> > > > >If ThisApplication.ActiveDocument.DocumentType =
> kDrawingDocumentObject
> > T
> > > hen
> > > > >
> > > > >'Check if file is set to Released
> > > > >
> > > > > ' Declare the Application object
> > > > >Dim oApplication As Inventor.Application
> > > > >
> > > > >' Obtain the Inventor Application object.
> > > > >' This assumes Inventor is already running.
> > > > >Set oApplication = GetObject(, "Inventor.Application")
> > > > >
> > > > >' Set a reference to the active document.
> > > > >' This assumes a document is open.
> > > > >Dim oDoc As Document
> > > > >Set oDoc = oApplication.ActiveDocument
> > > > >
> > > > >' Obtain the PropertySets collection object
> > > > >Dim oPropsets As PropertySets
> > > > >Set oPropsets = oDoc.PropertySets
> > > > >
> > > > >' Access the value of the "Design Status" Property
> > > > >Dim StatusValue As Variant
> > > > >StatusValue =
> > > >
> > >
> >
>
>oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDesi
> > > g
> > > > >nStatusDesignTrackingProperties).Value
> > > > >
> > > > >'If set to Released then print PDF file
> > > > >If StatusValue = "3" Then
> > > > >
> > > > >' Set a reference to the print manager object of the active
document.
> > > > > ' This will fail if a drawing document is not active.
> > > > > Dim oPrintMgr As DrawingPrintManager
> > > > > Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
> > > > >
> > > > > 'Set the printer
> > > > > oPrintMgr.Printer = "5D PDF Creator"
> > > > >
> > > > > ' Set to print in color.
> > > > > oPrintMgr.ColorMode = kPrintColorPalette
> > > > >
> > > > > ' Set to print two copies.
> > > > > oPrintMgr.NumberOfCopies = 2
> > > > >
> > > > > ' Set to print using portrait orientation.
> > > > > oPrintMgr.Orientation = kPortraitOrientation
> > > > >
> > > > > ' Set the paper size.
> > > > > oPrintMgr.PaperSize = kPaperSize11x17
> > > > >
> > > > > ' Get the name of the printer that will be used.
> > > > > If MsgBox("Using printer """ & oPrintMgr.Printer & """ Do you
> want
> > > to
> > > > >continue?", vbYesNo + vbQuestion) = vbNo Then
> > > > > ' Change to another printer.
> > > > > Dim sPrinterName As String
> > > > > sPrinterName = InputBox("Enter name of new printer:", "New
> > > Printer")
> > > > > If sPrinterName = "" Then
> > > > > Exit Sub
> > > > > Else
> > > > > oPrintMgr.Printer = sPrinterName
> > > > > End If
> > > > > End If
> > > > >
> > > > > ' Set to print all sheets.
> > > > > oPrintMgr.PrintRange = kPrintAllSheets
> > > > >
> > > > > ' Set to print full scale.
> > > > > oPrintMgr.ScaleMode = kPrintBestFitScale
> > > > >
> > > > > ' Submit the print.
> > > > > oPrintMgr.SubmitPrint
> > > > >
> > > > > ' Change the number of copies to 1.
> > > > > oPrintMgr.NumberOfCopies = 1
> > > > >
> > > > > ' Change the paper size to a custom size. The units are in
> > > centimeters.
> > > > > oPrintMgr.PaperSize = kPaperSize11x17
> > > > >
> > > > > ' Get and set the current sheet range.
> > > > > Dim iFromSheet As Long
> > > > > Dim iToSheet As Long
> > > > > Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
> > > > >
> > > > > ' Change the print range to print sheets 1 through 2.
> > > > > oPrintMgr.PrintRange = kPrintSheetRange
> > > > > Call oPrintMgr.SetSheetRange(1, 2)
> > > > >
> > > > > ' Submit the print.
> > > > > oPrintMgr.SubmitPrint
> > > > >
> > > > >Else
> > > > >End If
> > > > >
> > > > >Else
> > > > >End If
> > > > >
> > > > >End Sub
> > > > >
> > > > >--
> > > > >Sean Dotson, PE
> > > > >http://www.sdotson.com
> > > > >...sleep is for the weak..
> > > > >-----------------------------------------
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report