Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dwf save

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
229 Views, 6 Replies

dwf save

Is there a way to automatically save a dwf file automatically when the
drawing is saved.


Mark Rodgers



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

We used VBA to do this in MDT, havent looked at reprogramming it in Inventor
yet, but soon!

--
Paul Houlker
Rimex Supply Ltd
www.rimex.com
Message 3 of 7
hoser_71
in reply to: Anonymous

I have code that is writen into my idw templates that will automatically save a DWF to a specific folder.

There's a problem with centering the DWF if you use the Save As command to save a
DWF. It has been fixed if you download the DWFwriter and work it into the code.

When I get back to the office next week I'll post it.

Joe Bartels
Message 4 of 7
Anonymous
in reply to: Anonymous

I have two sets of code for creating a DWF to a
folder.  This one is the current one I use, and it runs off of the
DWFwriter that you can download from the Autodesk webpage.  This was built
using some code I was using to do a SaveAs to create the DWF.  I'll provide
that code in a following post.

 

Once the DWFwriter is installed open the
DWFwriter 2 Beta driver and under "Advanced
Properties" -> "DWF
Filename" to select "Don't prompt - use source
filename".  Make this choice
and the "Save As" dialog will not appear
any longer.

When DWFwriter 2 Beta is installed, a string value in the
registry is
created with an empty
value:

HKCU\Software\Autodesk\DWFwriter\2\Publish Directory

Change
this value to your desired target directory (with or without a
trailing \)
and your DWF files will land here.

 

I have also added code that will write text stating
it's a reference document, print the DWF, and then delete the text.  We do
this for our standards. 

 

Here's the code, take it a copy it into your IDW
template.  Everytime you do a save it will create the DWF to a specified
folder:

 

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.  Since this doesn't
use
    ' any text overrides, it will default to the active
text style.
    Dim sText As String
    Dim
oTextBox As TextBox
    sText = "<StyleOverride Bold='True'
FontSize='.4'>REFERENCE ONLY<Br/>NOT A RELEASED
DOCUMENT</StyleOverride>"
    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

 

   
    ' Check to see if a filename is
defined.
    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
   
   
oSketch.Delete
   
   
ThisApplication.SilentOperation = False
   
End
Sub

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> 
Message 5 of 7
Anonymous
in reply to: Anonymous

This is my old code that will do a SaveAs DWF to a specified folder. 
There are problems with this because it will not center the DWF correctly if
there is a view or object outside of the sheet boundary. 

 

You will have to copy it to your IDW template and
change your folder path.

 

 

 

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)

 

Set obDocument =
ThisApplication.ActiveDocument

 

If obDocument.DocumentType <> 12292
Then
        Exit
Sub
    Else
        Dim
szFileName As String
        Dim
szExtension As String

 

'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 save 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
           
obDocument.SaveAs szFileName, True
       
End If
    End If
End Sub

 

 
Message 6 of 7
Roxana
in reply to: Anonymous

Hello:

I am looking for a way to quickly save as DWF and wonder if you could give me feedback on this. Perhaps there is now something better than what you've suggested in this thread since I see it's a bit old. I am not a programmer, so I do not really understand what i would have to do with the code you are including here...

Any help would be great.

Thanks.
Message 7 of 7
Roxana
in reply to: Anonymous

Hello:

I am looking for a way to quickly save as DWF and wonder if you could give me feedback on this. Perhaps there is now something better than what you've suggested in this thread since I see it's a bit old. I am not a programmer, so I do not really understand what i would have to do with the code you are including here...

Any help would be great.

Thanks.

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

Post to forums  

Autodesk Design & Make Report