convert Inventor dwg to Autocad dwg problem?

convert Inventor dwg to Autocad dwg problem?

Anonymous
Not applicable
1,223 Views
2 Replies
Message 1 of 3

convert Inventor dwg to Autocad dwg problem?

Anonymous
Not applicable

Hi!

 

i'm usin the code bellow to convert a inventor dwg to a Autocad dwg, but a error is diplayed in the line:

"If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then"

 

the error displayed is:

 

-run time error '424':

object required

 

can someone tell me what is wrong here?

 

thanks.

 

 

 

Public Sub PublishDWG()
' Get the DWG translator Add-In.
Dim DWGAddIn As TranslatorAddIn
Set DWGAddIn =
ThisApplication.ApplicationAddIns.ItemById("{C24E3 AC2-122E-11D5-8E91-0010B541CD80}")

'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.CreateTranslation Context
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMa p

' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

Dim strIniFile As String
strIniFile = "C:\temp\Test.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If

'Set the destination file name
oDataMedium.FileName = "c:\temp\dwgout.dwg"

'Publish document.
Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

0 Likes
1,224 Views
2 Replies
Replies (2)
Message 2 of 3

jeff.pek
Community Manager
Community Manager

Hi -

 

Does this simplified approach work for you?

 

 

    Dim idwDoc As DrawingDocument
    Set idwDoc = ThisApplication.ActiveDocument
    
    Call idwDoc.SaveAsInventorDWG("c:\temp\test.dwg", True)
    Call ThisApplication.Documents.Open("c:\temp\test.dwg")

 

    Dim idwDoc As DrawingDocument

    Set idwDoc = ThisApplication.ActiveDocument

    Call idwDoc.SaveAsInventorDWG("c:\temp\test.dwg", True)

 

Jeff

0 Likes
Message 3 of 3

Ralf_Krieg
Advisor
Advisor

Hi

 

Is the Translator AddIn loaded? Setting a reference to the AddIn is not enough, it must be loaded.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes