0% found this document useful (0 votes)
54 views

Inventor Add-In Using C++ - CLR - Manufacturing DevBlog

The document discusses steps for creating an Inventor add-in using C++/CLR. It explains how to create a C++/CLR class library project, add references to necessary assemblies, implement the ApplicationAddInServer class, add metadata attributes, and create an .addin file to deploy the add-in. The source code for the project is provided in a GitHub link.

Uploaded by

VitorHugo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Inventor Add-In Using C++ - CLR - Manufacturing DevBlog

The document discusses steps for creating an Inventor add-in using C++/CLR. It explains how to create a C++/CLR class library project, add references to necessary assemblies, implement the ApplicationAddInServer class, add metadata attributes, and create an .addin file to deploy the add-in. The source code for the project is provided in a GitHub link.

Uploaded by

VitorHugo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

21/01/2017

InventorAddInusingC++/CLRManufacturingDevBlog

ManufacturingDevBlog
(http://adndevblog.typepad.com/manufacturing/)

TheresourceforsoftwaredevelopersworkingwithDesign,LifecycleandSimulationtechnologiesfromAutodesk.

03/09/2016

InventorAddInusingC++/CLR
ByAdamNagy(http://adndevblog.typepad.com/manufacturing/adamnagy.html)
Philippe(http://adndevblog.typepad.com/manufacturing/philippeleefsma.html)alreadycreatedasample(http://adndevblog.typepad.com/manufacturing/2012/07/creatingamix
managedinventoraddin.html)mixedmanaged(C++/CLR)addinthatyoucanhavealookat.ButIthoughtitcouldbeusefultolistthestepstoachievethat.Insteadofcreatinga
C++InventoraddinusingtheInventorAddInwizard,adding.NETsupporttoit,andseparatingthegeneratedcodefromthemanagedpartsusing#pragma
unmanaged/#pragmamanagedblocks,it'seasiertocreateaC++/CLRClassLibraryandimplementyourApplicationAddInServerin.NET.
1)Createthe"C++/CLRClassLibrary"preferablyinside"%APPDATA%\Autodesk\ApplicationPlugins"tomakeyourlifeeasier

(http://adndevblog.typepad.com/.a/6a0167607c2431970b01b8d1abe580970cpopup)
2)Createa"x64"platformfortheprojectandkeepthatactive
Insidethe"ConfigurationManager"dialog,under"Activesolutionplatform"select"<New...>"andaddthe"x64"platform

(http://adndevblog.typepad.com/.a/6a0167607c2431970b01b8d1abe3e4970cpopup)
3)Reference"Autodesk.Inventor.Interop.dll"
Click"PROJECT">>"References..."andbrowseto"<Inventorinstallfolder>\Bin\PublicAssemblies"andadd"Autodesk.Inventor.Interop.dll"
4)Insidethesamedialogboxalsoaddareferenceto"System.Windows.Forms"justsothatwecanshowamessageboxfromourcodelateron
5)Implementthe"ApplicationAddInServer"class
//MyClrAddIn.h
#pragmaonce
usingnamespaceSystem
usingnamespaceSystem::Runtime::InteropServices
usingnamespaceSystem::Windows::Forms
usingnamespaceInventor
namespaceMyClrAddIn{
publicrefclassStandardAddInServer:publicApplicationAddInServer
{
public:
StandardAddInServer(void)
{
}
virtualvoidActivate(ApplicationAddInSite^addInSiteObject,boolfirstTime)
{
MessageBox::Show("AddInLoading")
}

http://adndevblog.typepad.com/manufacturing/2016/03/inventoraddinusingcppclr.html

1/3

21/01/2017

InventorAddInusingC++/CLRManufacturingDevBlog

virtualvoidDeactivate()
{
MessageBox::Show("AddInUnloading")
}
virtualvoidExecuteCommand(intCommandID)
{
}
virtualpropertyObject^Automation
{
//Ifyouwanttoreturnaninterfacetoanotherclientofthisaddin,
//implementthatinterfaceinaclassandreturnthatclassobject
//throughthisproperty
Object^get()
{
returnnullptr
}
}
}
}
5)CreateaGUIDandaProgIdfortheclassandmakeitComVisible
namespaceMyClrAddIn{
[
ProgId("MyClrAddIn.StandardAddInServer"),
GuidAttribute("3543165F7F1946148842572A5EBE9549"),
ComVisible(true)
]
publicrefclassStandardAddInServer:publicApplicationAddInServer
{
//etc...
Note:youcanuseVisualStudio's"CreateGUID"dialogforcreatinganewGUID
7)Createan*.addinfileinsideyoursolution'sfolderwithname""andcontent
<?xmlversion="1.0"encoding="utf8"?>
<!TypeattributeissameasTyperegistrykey
(Standard,Translator,Plugin(Serveronly)>
<AddinType="Standard">

<!Shouldbethesameasthe"GuidAttribute"inMyClrAddIn.h>
<ClassId>{3543165F7F1946148842572A5EBE9549}</ClassId>
<ClientId>{3543165F7F1946148842572A5EBE9549}</ClientId>
<!Bothofthefollowingfieldsshouldbetranslated.
NOOTHERFIELDSSHOULDBETRANSLATED!>
<DisplayName>MyClrAddIn</DisplayName>
<Description>MyClrAddIn</Description>
<!AssumesthatMyClrAddIn.dllisinthesamefolderasthe*.addinfile>
<Assembly>MyClrAddIn.dll</Assembly>
<SupportedSoftwareVersionGreaterThan>17..</SupportedSoftwareVersionGreaterThan>
<LoadOnStartUp>1</LoadOnStartUp>
<Hidden>0</Hidden>
</Addin>
Hereisthesourcecodeoftheproject:
https://github.com/adamenagy/InventorAddInWithCLR(https://github.com/adamenagy/InventorAddInWithCLR)
Postedat02:23PMinAdamNagy(http://adndevblog.typepad.com/manufacturing/adamnagy/),Inventor(http://adndevblog.typepad.com/manufacturing/inventor/)|Permalink
(http://adndevblog.typepad.com/manufacturing/2016/03/inventoraddinusingcppclr.html)
(http://twitter.com/share?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddinusingcppclr.html&text=Inventor%20Add
In%20using%20C%2B%2B%2FCLR)
(https://plus.google.com/share?url=http://adndevblog.typepad.com/manufacturing/2016/03/inventoraddinusingcppclr.html)
(http://www.facebook.com/sharer.php?u=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddinusingcppclr.html)

Comments

Commentbeloworsigninwith Typepad(http://www.typepad.com/sitelogin?uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddin
usingcpp
clr.html&fp=0e34b7be75ddfa6db4c8e832f012608d&view_uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fprofile.typepad.com%2F&via=blogside&post_uri=http://adndevblog.typepad.com/manufacturing/2016/03/inv
addinusingcppclr.html) Facebook(http://www.typepad.com/sitelogin?uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddin
usingcpp
clr.html&fp=0e34b7be75ddfa6db4c8e832f012608d&view_uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fprofile.typepad.com%2F&via=blogside&service=facebook&post_uri=http://adndevblog.typepad.com/manufact
addinusingcppclr.html) Twitter(http://www.typepad.com/sitelogin?uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddin
usingcpp
clr.html&fp=0e34b7be75ddfa6db4c8e832f012608d&view_uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fprofile.typepad.com%2F&via=blogside&service=twitter&post_uri=http://adndevblog.typepad.com/manufactur
addinusingcppclr.html) Google+(http://www.typepad.com/sitelogin?uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddin
usingcpp
clr.html&fp=0e34b7be75ddfa6db4c8e832f012608d&view_uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fprofile.typepad.com%2F&via=blogside&service=gplus&post_uri=http://adndevblog.typepad.com/manufacturi
addinusingcppclr.html)andmore...(http://www.typepad.com/sitelogin?uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F03%2Finventoraddin
usingcpp

http://adndevblog.typepad.com/manufacturing/2016/03/inventoraddinusingcppclr.html

2/3

21/01/2017

InventorAddInusingC++/CLRManufacturingDevBlog

clr.html&fp=0e34b7be75ddfa6db4c8e832f012608d&view_uri=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fprofile.typepad.com%2F&via=blogside&service=openid&post_uri=http://adndevblog.typepad.com/manufactur
addinusingcppclr.html)

(URLsautomaticallylinked.)

Emailaddressisnotdisplayedwithcomment.

Name
EmailAddress
WebSiteURL
Post Preview

(http://www.typepad.com/)
ManufacturingDevBlog(http://adndevblog.typepad.com/manufacturing/)

http://adndevblog.typepad.com/manufacturing/2016/03/inventoraddinusingcppclr.html

3/3

You might also like