This is the code I'm using to print a DWF to a specified folder in Inventor.
About halfway in the macro the sketch is created, and then it's deleted at
the end of the macro when the DWF has been printed.
Option Explicit
Private obDocument As Document
Public WithEvents DocEvents As DocumentEvents
Public Sub AutoSave_Copy_by_Event()
Set DocEvents = ThisApplication.ActiveDocument.DocumentEvents
End Sub
Public Sub DocEvents_OnSave(ByVal BeforeOrAfter As EventTimingEnum, ByVal
Context As NameValueMap, HandlingCode As HandlingCodeEnum)
SaveAsType "dwf"
End Sub
Private Sub SaveAsType(szFileType As String)
ThisApplication.SilentOperation = True
Set obDocument = ThisApplication.ActiveDocument
If obDocument.DocumentType <> 12292 Then
Exit Sub
Else
Dim szFileName As String
Dim szExtension As String
Dim oPrintMgr As DrawingPrintManager
' Create a new sketch on the active sheet.
Dim oSketch As DrawingSketch
Set oSketch = obDocument.ActiveSheet.Sketches.Add
'Name the sketch
'oSketch.Name = "DWF"
' Open the sketch for edit so the text boxes can be created.
' This is only required for drawing sketches, not part.
oSketch.Edit
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Create text with simple string as input.
Dim sText As String
Dim oTextBox As TextBox
sText = "REFERENCE ONLY
NOT
A RELEASED DOCUMENT"
Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(1.5, 3),
sText)
' Exit the sketch from the edit environment.
oSketch.ExitEdit
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
'This is the name of the DWF printer on my system. Probably should
'Determine this by other means.
'Set the paper size
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oSheetSize As String
Set oSheet = oDrawDoc.ActiveSheet
' Set paper size.
If oSheet.Size = kADrawingSheetSize Then
oSheetSize = kPaperSizeLetter
'"B Size"
ElseIf oSheet.Size = kBDrawingSheetSize Then
oSheetSize = kPaperSize11x17
'"C Size"
ElseIf oSheet.Size = kCDrawingSheetSize Then
oSheetSize = kPaperSizeCustom
'"D Size"
ElseIf oSheet.Size = kDDrawingSheetSize Then
oSheetSize = kPaperSizeCustom
'"Custom Size"
ElseIf oSheet.Size = kCustomDrawingSheetSize Then
oSheetSize = kPaperSizeCustom
End If
oPrintMgr.Printer = "Autodesk DWFwriter"
oPrintMgr.NumberOfCopies = 1
oPrintMgr.Orientation = kLandscapeOrientation
oPrintMgr.ScaleMode = kPrintBestFitScale
oPrintMgr.PrintRange = kPrintAllSheets
oPrintMgr.PaperSize = oSheetSize
'get the full file name from obDocument
' szFileName = obDocument.DisplayName
'Determine the extension of the file
' szExtension = Right(szFileName, 3)
'If the extension is IDW then print a DWF of the file, if not do nothing
' If szExtension = "idw" Then
' szFileName = Left(szFileName, Len(szFileName) - 3) & szFileType
'szFileName = "I:\Autodesk Inventor\DWF\" & szFileName
' Call
ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, szFileName)
oPrintMgr.SubmitPrint
'End If
End If
'Delete Sketch
oSketch.Delete
ThisApplication.SilentOperation = False
End Sub
"Charles Bliss" wrote in message
news:3ffacc91$1_3@statler...
> Workarounds are acceptable but I am using Inventor and I suspect you are
> using AutoCAD where that might be a bit easier. If you are doing it
> with Inventor I would be very interested in learning more about the macro.
>
> Joe Bartels wrote:
>
> >We have a small program that's built into the drawing templates that will
> >print out a DWF to a specified folder on the server. The program
contains a
> >small macro that will create a sketch with text saying it's a reference
> >document, prints the DWF, and then deletes the sketch. It's not perfect,
> >but it works for us.
> >
> >Joe Bartels
> >
> >"Charles Bliss" wrote in message
> >news:3ff3b4ad$1_2@statler...
> >
> >
> >>Are there methods for adding water marking to DWF's? If not, when will
> >>a method be available?
> >>
> >>
> >>
> >
> >
> >
> >
>