Debug Inventor Addin (Inventor 2015 + Visual Studio Enterprise 2015)

Debug Inventor Addin (Inventor 2015 + Visual Studio Enterprise 2015)

lstarke
Contributor Contributor
4,131 Views
9 Replies
Message 1 of 10

Debug Inventor Addin (Inventor 2015 + Visual Studio Enterprise 2015)

lstarke
Contributor
Contributor

Hi,

 

Can someone teach how I can debug a Inventor addin ? I already have tryed a lot of tutorials sought in google but none works.

 

Thanks

0 Likes
4,132 Views
9 Replies
Replies (9)
Message 2 of 10

Boorda
Advocate
Advocate

I assume you are talking about debugging an Inventor add-in that you are creating correct?

 

If so then in your Visual Studio project for the add-in go to the project properties page. Under the debug tab in the "Start Action" area select "Start External Program" and point it to the path of the Inventor.exe file on your machine. (See First Image) If you do not see this section then you may be working with an older express version of Visual Studio. This used to be a feature only for the pro versions, but now it is a standard feature with the new Visual Studio 2015 Community edition which is free.

 

Find a spot in the code in which you would like the debugger stop and click in the gutter next to the code. (See Second Image) You should see a red dot in the gutter and when the executing code arrives at this spot the program will halt. You can then use F11 to step through your code line by line. F5 will run to the next debug break point or finish executing the code if no other break-points are found.


Automation is key!
0 Likes
Message 3 of 10

lstarke
Contributor
Contributor

Hi Boorba, firstly thanks for your help.

 

I did your steps and aparently it works. But how it works about the .dll and .addin, to make my addin working in Inventor I have to put the .dll and .addin in specific folders. In debugging mode, how it works ? 

My intention on debbug is undertand the UserInterface classes, I'm having a lot of headache trying to put a RibbonTab or something like that and want to debbug to find the errors.

0 Likes
Message 4 of 10

Boorda
Advocate
Advocate

You'll need to build your project/solution and copy the .dll & .addin files to one of two locations:

  1.) "C:\ProgramData\Autodesk\Inventor 2016\Addins\" <-- Change "Inventor 2016" to the year you have installed. In this folder the add-in will only load for that specific Inventor release.
  2.) "C:\ProgramData\Autodesk\Inventor Addins\" <-- In this folder the add-in will load in all Inventor versions starting at the version number specified in the .addin file using the <SupportedSoftwareVersionGreaterThan> tag. (This is the folder it typically use...)

 

Make sure the <Assembly> tag in your .addin file has the full path to where the .dll file resides.

 

One thing you can do to ease the pain of copying and pasting the .addin & .dll file after every build/rebuild is to add the following commands to the Post Build Events.

To get to the post build events go to Project Properties --> Compile --> Build Events --> Edit Post Build Events.

 

Paste in these commands, edit path as needed....

 

        xcopy /y "$(ProjectDir)Autodesk.$(TargetName).Inventor.addin" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"
        xcopy /y "$(TargetPath)" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"

 

If you are still having problems getting the addin to load after this post then you could zip up your project and I'll look at it for you.

 

-Addam


Automation is key!
Message 5 of 10

lstarke
Contributor
Contributor

Hi Boorba,

 

Thanks for your help, I'll try this asap.

 

Starke

0 Likes
Message 6 of 10

CadUser46
Collaborator
Collaborator

I ran into this problem as well and found it much more difficult to debug in visual studio than VBA.   I agree i found this information really hard to find and in fact i didnt.  I had to get a developer friend to help me.

 

Firstly using the Post Buld events is the proper way of doing it.  This is more a hack that you would need to fix before release.

 

In the project properties edit the compile build output path to be bin\debug and the configuration to be Debug.

In the debug menu change the start external program to be C:\Program Files\Autodesk\Inventor <version>\Bin\Inventor.exe

In windows you should end up with the .dll and the .pdb in the same folder namely bin\debug.  My memory eludes me but i think the first two settings should make this happen correctly.

As Boorda said make sure the assembly tag is correct pointing to where this .dll is created in your VS projects folder.

You only need to copy the .addin to the correct place, the dll stays in the debug folder for now.

 

When you launch the debugger in VS it should now connect correctly.

 

When your addin is finished one of the last steps would be to change the assembly tag to be the final location of the dll and rebuild.  When distributing it the .dll and the addin will be required.

 

Craig

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 7 of 10

lstarke
Contributor
Contributor

Boorda,

 

Can you post a real example of the commands bellow ?

 

xcopy /y "$(ProjectDir)Autodesk.$(TargetName).Inventor.addin" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"
xcopy /y "$(TargetPath)" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"
0 Likes
Message 8 of 10

CadUser46
Collaborator
Collaborator

I have edited this but you should get the idea and you'll need to change the extension to .bat

 

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 9 of 10

Boorda
Advocate
Advocate

xcopy /y "$(ProjectDir)Autodesk.$(TargetName).Inventor.addin" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"

xcopy /y "$(TargetPath)" "$(ALLUSERSPROFILE)\Autodesk\Inventor Addins\"

 

These are the exact commands that I use, you should be able to just copy and past the commands in you Build Events section.

The $(ProjectDir), $(TargetName) & $(TargetPath) are build macros that replace the paths automatically so you don't have explicitly type them out. Expand the Macros button in the Build events editor and you will see what I mean. 😉

 

The $(ALLUSERSPROFILE) automatically gets replaced with "C:\ProgramData\" or whereever the program data folder is for the current machine.
It's safer to use $(ALLUSERSPROFILE) just incase your machine's "ProgramData" folder is in a different location (very uncommon).


Automation is key!
Message 10 of 10

Boorda
Advocate
Advocate
By the way, if you are trying to debug your add-in, make sure you are using the "Start Debugging" or "F5" method in Visual Studio. Just opening Inventor will not actually start debugging and you wont hit any of the breakpoints that you've set. Debugging has to happen through Visual Studio. Also make sure you close Inventor first, if your project has any changes then it will automatically rebuild once you start debugging, thus why it is useful apply the commands above so that the .dll and .addin files are automatically moved to the correct locations.

Automation is key!
0 Likes