Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Save As DWG Error

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
506 Views, 3 Replies

Save As DWG Error

I'm not sure why this macro keeps getting hung up.

Can anyone help me with this?

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

I forgot to mention, I'm using Inv. 2010

Sample code attached

 

Mike

 

Message 3 of 4
Anonymous
in reply to: Anonymous

I remembered running the code to save as DWG back in R2008, so I cranked up 2008 again and it worked.

Why would it not work in R2010?

 

Mike

 

Message 4 of 4
Anonymous
in reply to: Anonymous


@Anonymous wrote:

I remembered running the code to save as DWG back in R2008, so I cranked up 2008 again and it worked.

Why would it not work in R2010?

 

Mike

 


I the other code since I couldn't get it to work in 2010.

I ended up modifying the sample from the Help file.

 

Mike

 

Public Sub SaveAsDWG()
    ' Get the DWG translator Add-In.
    Dim DWGAddIn As TranslatorAddIn
    Set DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-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.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 DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        Dim strIniFile As String
        strIniFile = "C:\vault workspace\Drawings\Wood_DWG.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
        Dim fname As String
    fname = oDocument.FullFileName
    fname = Left(fname, Len(fname) - 3) & "dwg"
    Dim iPath As Integer
    Dim sPath As String
    iPath = InStrRev(fname, "\")
    sPath = Left(fname, iPath)
   
    oDataMedium.FileName = fname
   
    'Publish document.
    Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

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

Post to forums  

Autodesk Design & Make Report