Hello
Taken from the Inventor programmers help:
Public Sub PrintDrawing()
' 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
' 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 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
' Set to print all sheets.
oPrintMgr.PrintRange = kPrintAllSheets
' Set to print full scale.
oPrintMgr.ScaleMode = kPrintFullScale
' 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 = kPaperSizeCustom
oPrintMgr.PaperHeight = 15
oPrintMgr.PaperWidth = 10
' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(iFromSheet, iToSheet)
MsgBox "Current sheet range is " & iFromSheet & " to " & iToSheet & Chr(13) & _
"Setting to print sheets 1-2."
' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange = kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)
' Submit the print.
oPrintMgr.SubmitPrint
End Sub
or for all sheets in a drawing
Public Sub PlotAllSheetsInDrawing()
'Print all sheets in drawing document
'Get the active document and check whether it's drawing document
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
Dim oDrgDoc As DrawingDocument
Set oDrgDoc = ThisApplication.ActiveDocument
' Set reference to drawing print manager
' DrawingPrintManager has more options than PrintManager
' as it's specific to drawing document
Dim oDrgPrintMgr As DrawingPrintManager
Set oDrgPrintMgr = oDrgDoc.PrintManager
' Set the printer name
' comment this line to use default printer or assign another one
oDrgPrintMgr.Printer = "HP LaserJet 4000 Series PCL 6"
'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.PrintRange = kPrintAllSheets
oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.SubmitPrint
End If
End Sub
And the sheetmetal export as dxf:
Public Sub WriteSheetMetalDXF()
' Get the active document. This assumes it is a part document.
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
' Get the DataIO object.
Dim oDataIO As DataIO
Set oDataIO = oDoc.ComponentDefinition.DataIO
' Build the string that defines the format of the DXF file.
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=R12&OuterProfileLayer=Outer"
' Create the DXF file.
oDataIO.WriteDataToFile sOut, "C:\temp\flat2.dxf"
End Sub
R. Krieg
RKW Solutions
www.rkw-solutions.com