runtime error

runtime error

Anonymous
Not applicable
428 Views
6 Replies
Message 1 of 7

runtime error

Anonymous
Not applicable
The following code was taken for the Inventor help files. When I run it I get the following Runtime error (see attached),
any help would be appreciated. thanks
-------------------------------------------------------------------

Public Sub PublishDWF()
'Set a reference to the AddIns collection
Dim AddIns As ApplicationAddIns
Set AddIns = ThisApplication.ApplicationAddIns

'Get the DWF translator AddIn
Dim DWFAddIn As TranslatorAddIn
Dim i As Integer
For i = 1 To AddIns.Count
If AddIns(i).AddInType = kTranslationApplicationAddIn Then
If AddIns(i).ClassIdString = "{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}" Then
Set DWFAddIn = AddIns.Item(i)
Exit For
End If
End If
Next i

'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(oDataMedium, oContext, oOptions) Then

oOptions.Value("Launch_Viewer") = 1

' Other options...
'oOptions.Value("Publish_Component_Props") = 0
'oOptions.Value("Publish_Mass_Props") = 0
'oOptions.Value("Password") = 0

If Typeof oDocument Is DrawingDocument Then

' Drawing options
oOptions.Value("Publish_All_Sheets") = 0

' 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

' Publish the third sheet but NOT its 3D model
Dim oSheet3Options As NameValueMap
Set oSheet3Options = ThisApplication.TransientObjects.CreateNameValueMap

oSheet3Options.Add "Name", "Sheet:3"
oSheet3Options.Add "3DModel", False

oSheets.Value("Sheet2") = oSheet3Options

'Set the sheet options object in the oOptions NameValueMap
oOptions.Value("Sheets") = oSheets
End If

End If

'Set the destination file name
oDataMedium.FileName = "c:\temp\test.dwf"

'Publish document.
Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
------------------------------------------------------------
0 Likes
429 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Using IV11 Dwf Extention.
Thanks Again
0 Likes
Message 3 of 7

Anonymous
Not applicable
Anybody.......HELP!!!!
0 Likes
Message 4 of 7

Anonymous
Not applicable
Fisher,

I've been able to reproduce the issue in the DWF Extension release. The
development team is investigating. Unfortunately, I don't know of a
workaround. I believe the best you can do for now is to publish the DWF
without options (using the SaveAs method on the Document by specifying a
.dwf file extension). Sorry for the bad news. I'll let you know if I learn
anything more.

Sanjay-

wrote in message news:5239810@discussion.autodesk.com...
Anybody.......HELP!!!!
0 Likes
Message 5 of 7

Anonymous
Not applicable
Sanjay,
Unfortunately I believe that will only "saveas dwf" the current active sheet. I have multiple sheet to dwf. I have downloaded the free dwf writer and am using the "DrawingPrintManager". I appreciate your efforts, and any other information you might acquire. Thanks
Wayne Fisher
0 Likes
Message 6 of 7

Anonymous
Not applicable
To fix the runtime error you can change
If DWFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
into
If DWFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

Also Inventor DWF Extenstion adds more control on publishing options. There
are "Express", "Complete" and "Custom" mode. To honor your publishing
options for drawing documents, you need to make sure the current (i.e., last
used) publishing model is "Custom", or you can add a new line in the script
oOptions.Value("Publish_Mode") = Inventor.kCustomDWFPublish

Peng Pan (Autodesk)


wrote in message news:5238619@discussion.autodesk.com...
The following code was taken for the Inventor help files. When I run it I
get the following Runtime error (see attached),
any help would be appreciated. thanks
-------------------------------------------------------------------

Public Sub PublishDWF()
'Set a reference to the AddIns collection
Dim AddIns As ApplicationAddIns
Set AddIns = ThisApplication.ApplicationAddIns

'Get the DWF translator AddIn
Dim DWFAddIn As TranslatorAddIn
Dim i As Integer
For i =
D 1 To AddIns.Count
If AddIns(i).AddInType = kTranslationApplicationAddIn Then
If AddIns(i).ClassIdString =
"{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}" Then
Set DWFAddIn = AddIns.Item(i)
Exit For
End If
End If
Next i

'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument

Dim oContext As TranslationContex
t
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.HasSave
CopyAsOptions(oDataMedium, oContext, oOptions) Then

oOptions.Value("Launch_Viewer") = 1

' Other options...
'oOptions.Value("Publish_Component_Props") = 0
'oOptions.Value("Publish_Mass_Props") = 0
'oOptions.Value("Password") = 0

If Typeof oDocument Is DrawingDocument Then

' Drawing options
oOptions.Value("Publish_All_Sheets") = 0

' The specified sheets will be ignored if
' the optio
n "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") = oSheet1Opt
ions

' Publish the third sheet but NOT its 3D model
Dim oSheet3Options As NameValueMap
Set oSheet3Options =
ThisApplication.TransientObjects.CreateNameValueMap

oSheet3Options.Add "Name", "Sheet:3"
oSheet3Options.Add "3DModel", False

oSheets.Value("Sheet2") = oSheet3Options

'Set the sheet options object in the oOptions NameValueMap
oOptions.Value("Sheets") = oSheets
End If


End If

'Set the destination file name
oDataMedium.FileName = "c:\temp\test.dwf"

'Publish document.
Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
------------------------------------------------------------
0 Likes
Message 7 of 7

Anonymous
Not applicable
Great!! Thanks to both of you for your efforts. It works perfect.!!
Thanks Again
Wayne Fisher
Mechanical Designer
0 Likes