Custom Translator Addin of Inventor – 1

By Xiaodong Liang

In default, Inventor has provided a bunch of translators of various formats such as *.dwg, *.dxf, *.sat etc. Each translator is actually an add-in which manages the Open or Save Copy As of the corresponding file format. e.g. when you open a *.sat file, the translator add-in of SAT will handle the open process to translate the file data to the geometries of Inventor. When you save copy as an Inventor file, the translator add-in will handle the save process to save geometies to the file.

The translator add-ins are grouped at the [Translator] tab of AddIn Manager. While what we normally create is a kind of standard add-in which is listed at [Applications] tab.

clip_image001[4]

You can find their *.addin file at:
\ProgramData\Autodesk\Inventor ***\Addins.

The *.dll are deployed at
<Inventor Installation Path>\bin\

I believe you have known API allows you to drive the default add-in to customize the Open/Save options to achieve the specific requirements.

API also allows you to create custom translator add-in, by which you can resolve custom file format to the geometries in Inventor, or conversely.

The basic structure of the stardard add-in and translator add-in are same:

  1. It is a class library (*.dll ) 
    2. A *.X.Manifest file is used to build with the *.dll 
    3. A *.addin file configures the behaviors of the add-in.

The difference are: 
1.  The class of stardard add-in derives from ApplicationAddInServer, while the class of translator add-in derives from TranslatorAddInServer.

  1. Except the Activate and Deactivate methods, the class must override more methods of TranslatorAddInServer:

        Open: Open the data specified by the data-source.
        SaveCopyAs: Save the document to the specified data- 
        source.
        HasOpenOptions: Gets whether the translator has 
        options available for opening the specified data-source.
        HasSaveCopyAsOptions: Gets whether the translator has
        options available for saving the specified data-source.
        ShowSaveCopyAsOptions: Show the save options for the
        specified data-source. This method is only called if True was
        returned from HasSaveCopyAsOptions
        GetThumbnail: Obtains the thumbnail, if any, for the given
        data-source

  1. There are some special tags with the *.addin file of the translator add-in.

 <AddinType="Translator">
The XML head tag specifies the add-in type

<SupportsOpenInto>.ipt;.iam</SupportsOpenInto>

Indicates the environments which support to open the custom file format

 

<SupportsImportInto>.ipt</SupportsImportInto>
Indicates the environments which support to import the custom file format


<
SupportsSaveCopyAsFrom>.ipt;.iam</SupportsSaveCopyAsFrom>
Indicates the environments which support to Save Copy As
the geometries to custom file format

<FileExtensions>.abc</FileExtensions>
Indicates the extension name of the custom format.


<
FilterTextLanguage="1033">ABC Files (*.abc)</FilterText>
Indicates the text for [Files of Type] of Open/ Save Copy As  dialog
<
SupportsOpen>1</SupportsOpen>
Indicates whether it supports Open

<SupportsImport>1</SupportsImport>
Indicates whether it supports Import

<SupportsSaveCopyAs>1</SupportsSaveCopyAs>
Indicates whether it supports Save Copy As

The Inventor Wizard of C++ provides the option to create a translator add-in skeleton. But wizard of .NET has not yet provided it. I made a copy of .NET wizard and changed the template for the translator add-in. The template of C# is attached. Please copy to

<Documents>\ Visual Studio ***\Templates\ProjectTemplates\ .
Download VCSInventorTranslatorAddInTemplate2014

I will produce VB.NET version later.

Now, I will demo how to imeplement a custom translator add-in for a file format *.abc. The demo mimics the C++ sample :

SDK\DeveloperTools\Samples\VC++\AddIns\Translator

In this demo, I define data in an *.abc file: two for a sphere center point and radius, the other is for product number of iProperties. When an *.abc file is opened, the add-in will create a part document, read the *.abc file, build a sphere with the radius and update product number of iProperties with the data.

When saving to an *.abc file, the translator will get data of an existing sphere surface of a part and the current part number, save them to the *.abc file.

Firstly, let us create a skeleton of translator add-in by the wizard.
Start Visual Studio, select the template [Autodesk Inventor 2014 Translator AddIn]

clip_image002

The project is created with a class derives from TranslatorAddInServer and the necessary override methods.

clip_image003

Open Autodesk.MyTranslator.Inventor.addin to make sure the options. In default, the *.addin file is

<AddinType="Translator">

  <!–Created for Autodesk Inventor Version 18.0–>

  <ClassId>{f4c4d6ac-3354-457b-ad49-626583d640d9}</ClassId>

  <ClientId>{f4c4d6ac-3354-457b-ad49-626583d640d9}</ClientId>

  <DisplayName>MyTranslator</DisplayName>

  <Description>MyTranslator</Description>

  <Assembly>MyTranslator.dll</Assembly>

  <SupportsOpenInto>.ipt;.iam</SupportsOpenInto>

  <SupportsImportInto>.ipt</SupportsImportInto>

  <SupportsSaveCopyAsFrom>.ipt;.iam</SupportsSaveCopyAsFrom>

  <FileExtensions>.abc</FileExtensions>

  <FilterTextLanguage="1033">ABC Files (*.abc)</FilterText>

  <SupportsOpen>1</SupportsOpen>

  <SupportsImport>1</SupportsImport>

  <SupportsSaveCopyAs>1</SupportsSaveCopyAs>

  <LoadOnStartUp>0</LoadOnStartUp>

  <UserUnloadable>1</UserUnloadable>

  <Hidden>0</Hidden>

  <ExtraInfo>1</ExtraInfo>

</Addin>

You can change the option with your requirements.

 

After building, the add-in is deployed to
%AppData%\Autodesk\ApplicationPlugins

Launch Inventor, in open dialog or save dialog, you can see the option *.abc is available. I’d suggest you could debug the project to see if the Open or SaveCopyAs method would be invoked when opening or saving to an *.abc.

 

image

 

The next post will implement the Open & SaveCopyAs workflow.

( to be continued)


Comments

2 responses to “Custom Translator Addin of Inventor – 1”

  1. Eugene Rymski Avatar
    Eugene Rymski

    Thanks for the useful article!
    Just want to add that for me it worked then I changed deployment path to “%AppData%\Autodesk\Inventor 2014\Addins\”.

  2. Scott Wagner Avatar
    Scott Wagner

    Will this technique work for Inventor ETO Server 2023 R2. It works for Inventor ETO Series 2013 R2. I have tried it but cant seem to get the thing working anything special i need to do.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading