Inventor General

Active Contributor
Posts: 31
Registered: ‎01-16-2013
Message 1 of 2 (364 Views)

ilogic to save multiple formats

364 Views, 1 Replies
03-01-2013 07:47 AM



Found a couple of threads about this, but no one with my problem.


I have the following code:

strFile = ThisDoc.FileName(False) & "-Rev " & iProperties.Value("Project", "Revision Number")
ThisDoc.Document.SaveAs(strFile & (".dwg"), True)
ThisDoc.Document.SaveAs(strFile & (".pdf"), True)

And it works like a charm for pdf, but it does not export to .dwg? Any ideas?


And also, is it possible to decide where in the name the "-Rev " &iPro....should appear?

Ex. if the filename should be : "12345 - Rev 02 - Section cut"


Valued Contributor
Posts: 101
Registered: ‎09-13-2012
Message 2 of 2 (320 Views)

Re: ilogic to save multiple formats

03-03-2013 06:55 AM in reply to: 128848

When you want to save to an autocad DWG you need to give iLogic more info. Normally when you do a save copy as dwg you configure to which dwg-version, what scale system and dimensionblocks and other..

First create an ini file by creating a dwg the way you want it manually and save the configuration to "C:\temp\acad.ini"

In iLogic you use this ini file. Here is the code, it's a bit more difficult than the standard save as pdf.


' Get the DWG translator Add-In.
Dim DWGAddIn As TranslatorAddIn
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
oDocument = ThisApplication.ActiveDocument

Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium
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\acad.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 fileName As String
fileName = ThisDoc.FileName(False) & " -Rev " & iProperties.Value("Project", "Revision Number") & " Section cut "
oDataMedium.FileName = "c:\temp\" & fileName & ".dwg"

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


This code will save the dwg to your C:\temp, but you can change that to any location.

Hope this helps you.




Autodesk Inventor 2012 Certified Associate & Autodesk Inventor 2012 Certified Professional.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor