Message 1 of 16
Inventor API: Publish DWF with Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having some trouble with the attached VBA script to publish a DWF. I'm trying to publish all sheets if it's a drawing but also include the 3DModel from the 1st sheet and do not include the structured BOM. I can't get the combination of those options to work correctly.
Public Sub PublishDWF(fFilename As String) ' Get the DWF translator Add-In. Dim DWFAddIn As TranslatorAddIn Set DWFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}") 'Set a reference to the active document (the document to be published). Dim oDocument As Document Set oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext Set oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If DWFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then oOptions.Value("Launch_Viewer") = 0 ' Other options... oOptions.Value("Publish_All_Component_Props") = 1 oOptions.Value("Publish_All_Physical_Props") = 1 oOptions.Value("BOM_Structured") = 0 'oOptions.Value("Password") = 0 If TypeOf oDocument Is DrawingDocument Then ' Drawing options oOptions.Value("Publish_Mode") = kCustomDWFPublish 'oOptions.Value("Publish_All_Sheets") = 1 ' The specified sheets will be ignored if ' the option "Publish_All_Sheets" is True (1) Dim oSheets As NameValueMap Set oSheets = ThisApplication.TransientObjects.CreateNameValueMap ' Publish the first sheet AND its 3D model Dim oSheet1Options As NameValueMap Set oSheet1Options = ThisApplication.TransientObjects.CreateNameValueMap oSheet1Options.Add "Name", "Sheet:1" oSheet1Options.Add "3DModel", True oSheets.Value("Sheet1") = oSheet1Options 'Set the sheet options object in the oOptions NameValueMap oOptions.Value("Sheets") = oSheets End If End If 'Set the destination file name oDataMedium.FileName = fFilename + ".dwf" 'Publish document. Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub