Edit, build and debug Add-in's .vcxproj in Visual Studio Code?

Edit, build and debug Add-in's .vcxproj in Visual Studio Code?

LiveLover
Advocate Advocate
4,360 Views
3 Replies
Message 1 of 4

Edit, build and debug Add-in's .vcxproj in Visual Studio Code?

LiveLover
Advocate
Advocate

Hello! 
We create C++ Add-in in Fusion360 GUI.
We have a Folder with files:
NewScript1.cpp
NewScript1.dll
NewScript1.dylib
NewScript1.manifest
NewScript1.vcxproj
NewScript1.xcodeproj

We are on Windows10.

How to develop it? How to open it with full IDE support? How to compile? is Visual Studio Code suitable? 

Stuck here (

Help please.

4,361 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor

I responded to another related question of yours before I read this one.  I provided a link to some C++ specific documentation.  However, I'm not sure it answers all your questions.

 

The manifest file is a JSON file that has information about your add-in that Fusion uses to correctly display and run your add-in.  There is a section in the help article about Creating Scripts and Add-Ins that describes the contents of the manifest file. 

 

The cpp file is the source code for the add-in.

 

The vcxproj is the project file for Visual Studio. On a Windows machine with Visual Studio installed, you can double-click this file to open the project in Visual Studio.  This is the standard Visual Studio, not Visual Studio Code.  The xcodeproj file is the equivalent for Mac and can be used with XCode.

 

I'm surprised you have the dll and dylib files.  The dll is created when you compile the project on a windows machine and is the runtime library that will be used when your add-in is used on Windows.  The dylib file is the equivalent for Mac and can only be created by compiling your project on a Mac.

 

If you are new to programming, C++ has a much higher learning curve than Python.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 4

LiveLover
Advocate
Advocate

Brian Ekins thank you for your response!

C\C++ is much familiar then Python for me. But I'm experienced mostly with Linux and GCC. That is why I'm looking for some starters materials.

MS VS opens Add-in project (and it is surprising free).

 

But I feel lack of understanding with all what all these
""
#ifdef XI_WIN

#include <windows.h>

BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{""
are
and how/when compiled code (dll?) is loaded into Fusion and so on.

And debugging not working for me (
 The breakpoint will not currently be hit. No symbols have been loaded for this document 

How to deal with it?

I'm reading official documentation, it's ReallyGood!!

0 Likes
Message 4 of 4

BrianEkins
Mentor
Mentor

The #ifdef is referencing a Windows-specific header file when you're compiling with Visual Studio.  A big difference between using C++ and Python is that most Python code will run as-is on either Windows or Mac.  Typically, you can develop your add-in on one and it will automatically work on the other. The times it won't is when you're making an OS-specific call, like accessing the Windows registry.

 

With C++ you can typically get by with one set of source code but you have to compile it specifically for Windows or Mac.  Unlike with Python, there are always some differences in the source code, which explains why the #ifdef is there.  Compiling under Windows with Visual Studio will create a dll.  Compiling on Mac with XCode will create a dylib.  If you want to support both platforms you need to install the dll on Windows and the dylib on Mac.

 

Each add-in has its own folder, which is the same name as the dll and dylib file.  In that folder is the dll or dylib and also the .manifest file with the same name.  There are some standard folders where Fusion looks for add-ins. Within those folders, it looks for subfolders and within those, it looks for manifest files. If the manifest file indicates the add-in should be loaded at start-up, Fusion will load the dll or dylib file and the add-in will start running.  You can manage your add-ins through the "Scripts and Add-Ins" command where you can see a list of scripts and add-ins that Fusion has found. For each add-in, you can specify if it should run automatically at start-up or not.

 

I don't know what the problem with debugging is.  I just tried it myself and was able to start successfully debugging a script using the directions from here: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-ECC0A398-4D89-4776-A054-F7B432F7FCF6#Debuggi...

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes