BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Attach to Process issues in VS 2022 / AC27

Sam Karli
Enthusiast

Hi all,

I have problems attaching to ArchiCAD process in current VS/AC.

Note that the problem is not stable, ie. sometimes (most times, unfortunately) happens but sometimes things work.

For breakpoints I see the ordinary "The breakpoint will no currently be hit. No Symbols have been loaded for this document." The .pdb is written so on the VS side I think everything is as advertised.

When I check the loaded modules (Debug/Windows/Modules window), mostly I don't see my .apx as a loaded module.

Sometimes I see it, and guess, then breakpoints work then. (PS when I kind of enforce loading it through "Options/Add-On Manager..." it loads more times successfully than ordinarily.)

The life cycle of the addon is quite ordinary, I use the default Initialization (ie. I have copied it from an Example module) and the addon actually works as it should work. 

 

 

 

// -----------------------------------------------------------------------------
// Called when the Add-On has been loaded into memory
// to perform an operation
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL	Initialize (void)
{
	GSErrCode err;
	err = ACAPI_Install_MenuHandler (32506, PropertyPalette);
	return err;
}		/* Initialize */

 

 

 

The only problem is that in most cases I don't see it in modules and I can't use breakpoints. As far as I understand this is a new AC27 issue (I haven't seen similar problems between AC18-AC26 that I have some experience of).

 

PS2 a related problem is that many times I have no write right to the .apx (Getting LNK1104 cannot open file 'Build\Debug 27\PropertyPalette_27.apx' obviously because ArchiCAD sits on the file). Any ideas of being able to write the apx by, like, forcing to unload from ArchiCAD?
)

 

Any ideas?
Thanks in advance.

GDL/Python/C++ dev
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi Sam,

 

It took me a while to get my head around the loading/unloading of Add-Ons and attaching the debugger.

 

Here's what always works for me:

  1. Unload Add-On from Archicad by unticking checkbox in Add-On Manager and confirm with OK.
    This might prompt for saving and closing project depending on your Add-On. You need to confirm to properly unload the Add-On.
  2. Now you should be able to build the Add-On and overwrite the .apx file
  3. Attach the debugger to the Archicad process
  4. AFTER attaching the debugger, load the Add-On again by ticking the checkbox in the Add-On Manager and confirm with OK.
    (This might again prompt for saving and reopening of the project if your Add-On is specified as APIAddOn_Preload. - Need to confirm this again for proper loading)

After that the VS Debugger should recognize that the Add-On is loaded in Archicad and you should be able to activate breakpoints etc.

Let me know if this also works for you.

 

If you have a APIAddOn_Normal and don't use any other techniques that require the Add-On to stay loaded in Archicad (so no Notification Manager, Element Observs, Paletts, etc. -- generally nothing that reacts on events by Archicad) then this often also works without the Unloading and Loading of the Add-On. This difference is where you might have seen the inconsistent behavior.

 

But on the other hand, if you change certain things in resource files like menu strings, you even have to remove the Add-On from the Add-On Manager so that the Register Interface function of your Add-On is executed again.

 

Hope that helps,
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

View solution in original post

2 REPLIES 2
Solution

Hi Sam,

 

It took me a while to get my head around the loading/unloading of Add-Ons and attaching the debugger.

 

Here's what always works for me:

  1. Unload Add-On from Archicad by unticking checkbox in Add-On Manager and confirm with OK.
    This might prompt for saving and closing project depending on your Add-On. You need to confirm to properly unload the Add-On.
  2. Now you should be able to build the Add-On and overwrite the .apx file
  3. Attach the debugger to the Archicad process
  4. AFTER attaching the debugger, load the Add-On again by ticking the checkbox in the Add-On Manager and confirm with OK.
    (This might again prompt for saving and reopening of the project if your Add-On is specified as APIAddOn_Preload. - Need to confirm this again for proper loading)

After that the VS Debugger should recognize that the Add-On is loaded in Archicad and you should be able to activate breakpoints etc.

Let me know if this also works for you.

 

If you have a APIAddOn_Normal and don't use any other techniques that require the Add-On to stay loaded in Archicad (so no Notification Manager, Element Observs, Paletts, etc. -- generally nothing that reacts on events by Archicad) then this often also works without the Unloading and Loading of the Add-On. This difference is where you might have seen the inconsistent behavior.

 

But on the other hand, if you change certain things in resource files like menu strings, you even have to remove the Add-On from the Add-On Manager so that the Register Interface function of your Add-On is executed again.

 

Hope that helps,
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hm, to be honest, I had never started/attached to an ArchiCAD like this (attaching the process and AFTER THAT loading the addon).

BTW stuff works now, thanks.

GDL/Python/C++ dev
Learn and get certified!