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: 

Sample code for Inventor Add in DLL for VB .NET

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
Anonymous
5214 Views, 12 Replies

Sample code for Inventor Add in DLL for VB .NET

I tried the My first plug in program of Inventor. That contains VB .NET program which creates a standalone EXE. This program worked very fine.

Where can I find similar program on how to develop VB .NET Add-in DLL and also explain how to launch it inside Inventor (similar to NETLOAD and <CommandName> in AutoCAD 2012)?

I am using Autodesk Inventor 2014 Professional and Visual Studio 2012

Thanks

PV Subramanian

12 REPLIES 12
Message 2 of 13
Owner2229
in reply to: Anonymous

Hi, I'm not realy sure if there is an official "walk-throught" for whole creation of an Add-In.

But over time I have created my own template for it, including Ribbon buttons and some basic events.

You can find it in attachment. Extract it, run the _New Inventor Addin.bat, write in NewProjectName and it'll rename all needed parts of the code.

 

I've made this template for my use, as the program I'm ussing (SharpDevelop) doesn't have clasic templates and I find this easier.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 13
pball
in reply to: Owner2229

I found this pdf which seems to be from Autodesk University some years ago. I haven't gotten too far into it yet but it helped me sucessfully get addin templates working in VS 2012.

 

http://modthemachine.typepad.com/files/VBAtoAddIn.pdf

Message 4 of 13
Anonymous
in reply to: pball

Even I read that PDF and tried the solution provided in that. I got compilation errors. I have attached the VS 2012 error as a snapshot.

In VS 2012 I got the following 2 errors

 

Error 1 End of statement expected.

D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorFirstSampleProgram\InventorFirstSampleProgram\InventorFirstSampleProgram.vb 10 38 InventorFirstSampleProgram

 

in Line

Public Class StandardAddInServer Implements Inventor.ApplicationAddInServer

 

 

Another compilation error

Error 2 Interface 'Inventor.ApplicationAddInServer' is not implemented by this class. 

D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorFirstSampleProgram\InventorFirstSampleProgram\InventorFirstSampleProgram.vb 37 124 InventorFirstSampleProgram

 

in Line

Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

 

 

Message 5 of 13
Anonymous
in reply to: Owner2229

Thanks for your templates. Your batch file worked like a charm.

When I built the project using VS Professional 2012 got few errors

All the errors are related to m_AppEvents is not declared. I have attached the project that was created my running your batch file, as a zip file. The zip file includes a snapshot (jpeg image) of the error message from Visual Studio 2012. 

Can you please let me know how to fix these errors?

 

Error 10 'm_AppEvents' is not declared. It may be inaccessible due to its protection level. D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\ClassModules\StandardAddInServer.vb 38 15 InventorSampleProg 

Error 11 'm_AppEvents' is not declared. It may be inaccessible due to its protection level. D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\ClassModules\StandardAddInServer.vb 39 15 InventorSampleProg

Error 12 'm_AppEvents' is not declared. It may be inaccessible due to its protection level. D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\ClassModules\StandardAddInServer.vb 40 15 InventorSampleProg

Error 13 'AddresOf' is not declared. It may be inaccessible due to its protection level. D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\ClassModules\StandardAddInServer.vb 40 42 InventorSampleProg

Error 14 End of statement expected. D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\ClassModules\StandardAddInServer.vb 40 51 InventorSampleProg

 

 

 

 

Message 6 of 13
Owner2229
in reply to: Anonymous

Hi, try it now. There've been some lines missing or broken n the template (probably hapened when I was cleaning it Smiley Happy ).

I'm sending you also the corrected template.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 13
Anonymous
in reply to: Anonymous

By the way, I am trying to run the Visual Studio 2012 VB .NET code in Autodesk Inventor 2014 Professional

Message 8 of 13
Anonymous
in reply to: Owner2229

Thanks a lot for the updated template. One last compilation error. I have attached the JPEG.

I am using Visual Studio 2012; I also have Visual Studio 2010. Looks like the VS 2012 is compiling using VS 2010 compiler. Unfortunately there is some issue in accessing the MSDN forum. In case you know a quick fix for this please let me know.

 

Error 1 The command "call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" mt.exe -manifest "D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\InventorSampleProg.X.manifest" -outputresource:"D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\InventorSampleProg.dll";#2
copy D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\InventorSampleProg.dll "C:\Program Files\Autodesk\ApplicationPlugins\"
copy D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\SVOS.InventorSampleProg.Inventor.addin "C:\ProgramData\Autodesk\Inventor Addins\"" exited with code 1. InventorSampleProg

 

Message 9 of 13
Anonymous
in reply to: Anonymous

I tried using Visual Studio 2010 Express and the same compilation error. Please find attached the image of the error

 

The error message is

 

Error 1 The command "call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" mt.exe -manifest "D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\InventorSampleProg.X.manifest" -outputresource:"D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\InventorSampleProg.dll";#2
copy D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\InventorSampleProg.dll "C:\Program Files\Autodesk\ApplicationPlugins\"
copy D:\DesignAutomation\AutodeskInventor_CodeDevelopment\InventorSampleProg\bin\SVOS.InventorSampleProg.Inventor.addin "C:\ProgramData\Autodesk\Inventor Addins\"" exited with code 1. InventorSampleProg

Message 10 of 13
Jef_E
in reply to: Anonymous

The error is generated because the file probably doesnt exist at this location? Please check.

 

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" mt.exe -manifest "$(ProjectDir)$(AssemblyName).X.manifest" -outputresource:"$(TargetPath)";#2


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 11 of 13
Anonymous
in reply to: Jef_E

Yes. You are right . C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat is missing.

Can you please tell me how to fix this? I think this was part of the template provided by

 THanks

PV Subramanian                       

 

Message 12 of 13
Anonymous
in reply to: Anonymous

The Sample Invetor Add in program worked.

The attached zip file contains a working Inventor Add-in sample program. I have also attached a image showing that the InventorSampleProg worked successfully. I changed the Message from

    Some cool stuff happenin' here...

to

    Some cool stuff happenin' here... Successfully Launched Inventor Sample Prog

 

This is what I did

I took the modified Template Addin_Template.zip provided by Owner2229
 
I did the following steps
1) Modified _New Inventor Addin.bat in which the last line was modified : replaced %InputFile4% with %InputFile5%
2) Ran the _New Inventor Addin.bat and created the InventorSampleProg project/solution
3) Launched Visual Studio 2012

4) Opened the solution InventorSampleProg.sln. There were few Visual Studio pop-up messages (like One Way Upgrade), which I accepted

5) Ensured that the reference Autodesk.Inventor.Interop.dll added correctly (the path)

6) Then opened the Compile tab of the Project Properties by right clicking on the project. Scrolled to the bottom and clicked on the "Build Events" button on the right side 

7) Deleted all the lines in "Post-build event command line" and clicked on "OK". This post-build event was causing the error of "Error 1 The command "call "C:\Program File.........."

8) Successfully ran the "Build Solution" which compiled and created the InventorSampleProg.dll 

9) Read the "Getting Started with Inventor's API" by clicking on the Help-->Community Resources--> Programming Help . Created a folder named InventorSampleProg in C:\Users\<UserID>\AppData\Roaming\Autodesk\ApplicationPlugins . In the InventorSampleProg folder I copied the InventorSampleProg.dll and the SVOS.InventorSampleProg.Inventor.addin.

10) Renamed SVOS.InventorSampleProg.Inventor.addin to Autodesk.InventorSampleProg.Inventor.addin

11) Edited the Autodesk.InventorSampleProg.Inventor.addin file. In the <Assembly> tag removed the Folder Location (Path) to InventorSampleProg.dll.

      The line should look like this  <Assembly>InventorSampleProg.dll</Assembly>

12) Launched Inventor 2014 Pro

13) Opened an assembly and in the Assemble Tab, saw the InventorSampleProg button with "I" ICON.

14) Clicked on the  InventorSampleProg button and got the message " Some cool stuff happenin' here... ". Then modified the message, and repeated the process and successfully saw the updated message.

 

Thanks a lot for Owner2229 for providing the updated / fixed AddIn Templates and for Jef_E pointing out to the possible issue.

PV Subramanian

Message 13 of 13
xiaodong_liang
in reply to: Anonymous

Hi,

It looks Owner2229 and Jef_E have helped you with the solution. And thank you for sharing the updated samples and steps. I believe other developers can also benefit from this material:)

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report