Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Can addon behave like the normal buiding elements tools ?

julienK
Advocate

When using  walls, colums etc in AC  the tool stays active after you finish your input.

 

Is it possible to get this behaviour for an addon?

I have a palette with an icon that let me place a text element, but i have to reclick the icon for each new text element.

Is there a way to make this comand 'sticky' so i can reuse it multiple time ?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Thanks for the clarification. I misunderstood your question.

 

If I understand it correctly now, I think you would have to manage that manually by e.g. having a loop in your ButtonClicked event observer and stop the loop once the user cancels the input. For example the function APIIo_GetPointID returns APIERR_CANCEL when users cancel the input.


Does this address your issue? Otherwise could you provide the code of your ButtonClicked event observer?

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

View solution in original post

4 REPLIES 4

Hi!

Are you using an `IconButton`?
I think the behavior you want should work with an `IconPushCheck`.

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

I do use an iconButton on my palette, yes.

The issue is not to retain some parameter that works just fine, the issue is that I want the command linked to that button to stay active once the first iteration is finished.

 

In the palette I have  a buttonclicked event observer, what I want it the function lnked to the button to be called again once it completes.

Solution

Thanks for the clarification. I misunderstood your question.

 

If I understand it correctly now, I think you would have to manage that manually by e.g. having a loop in your ButtonClicked event observer and stop the loop once the user cancels the input. For example the function APIIo_GetPointID returns APIERR_CANCEL when users cancel the input.


Does this address your issue? Otherwise could you provide the code of your ButtonClicked event observer?

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

Sorry I forgot to come back to say I found the solution.

Like you suggested  i changed my function return type to GSErrCode and wrapped it in  a do-while loop.

 

	 GSErrCode Do_iterate() {
		 GSErrCode err;
		 do {
			 ACAPI_CallUndoableCommand("Iterated element",
				 [&]() -> GSErrCode {
					 err = Do_CreateText();
					 return NoError;
				 });
		 } while (err == NoError);
		 return err;
	 }

 

 

my Do_CreateText function calls ClickAPoint() from APICommon.c whick does return  APIERR_Cancel

 

 

Thanks for the help.