Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Palette question

juliencuadra
Participant
I managed to get my first add-on to work. Now I'd like to make it look good.

- Is it possible to make an add-on palette dockable like the default archicad palettes to integrate it nicely in the UI.

- The API documentation only mentions palettes, not toolbars. Is it possible to create toolbars, also dockable like the archicad ones ?
3 REPLIES 3

Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
juliencuadra wrote:
- Is it possible to make an add-on palette dockable like the default archicad palettes to integrate it nicely in the UI.
Yes, it's possible.
You have to assign a guid to your palette. Use the constructor of DG::Palette parent class which has GS:Guid parameter:
Palette (GSResModule resModule, short resId, GSResModule dialIconResModule, const GS::Guid& guid);
And do not forget to register your palette as a modeless window by using ACAPI_RegisterModelessWindow function.
Example code (copied from Browser Control example Add-On, http://archicadapi.graphisoft.com/browser-control-and-javascript-connection):
static const GS::Guid	paletteGuid ("{ED852AD6-15E7-4812-AD88-FA1682E5D33C}");

...

MyPalette::MyPalette () :
	DG::Palette (ACAPI_GetOwnResModule (), MyPaletteResId, ACAPI_GetOwnResModule (), paletteGuid),
	...
{
	...
}


GSErrCode __ACENV_CALL	PaletteControlCallBack (Int32, API_PaletteMessageID messageID, GS::IntPtr param)
{
	switch (messageID) {
		case APIPalMsg_OpenPalette:
			if (!HasInstance ())
				CreateInstance ();
			GetInstance ().Show ();
			break;

		case APIPalMsg_ClosePalette:
			if (!HasInstance ())
				break;
			GetInstance ().Hide ();
			break;

		case APIPalMsg_HidePalette_Begin:
			if (HasInstance () && GetInstance ().IsVisible ())
				GetInstance ().Hide ();
			break;

		case APIPalMsg_HidePalette_End:
			if (HasInstance () && !GetInstance ().IsVisible ())
				GetInstance ().Show ();
			break;

		case APIPalMsg_DisableItems_Begin:
			if (HasInstance () && GetInstance ().IsVisible ())
				GetInstance ().DisableItems ();
			break;

		case APIPalMsg_DisableItems_End:
			if (HasInstance () && GetInstance ().IsVisible ())
				GetInstance ().EnableItems ();
			break;

		case APIPalMsg_IsPaletteVisible:
			*(reinterpret_cast<bool*> (param)) = HasInstance () && GetInstance ().IsVisible ();
			break;

		default:
			break;
	}

	return NoError;
}



GSErrCode __ACENV_CALL	Initialize (void)
{
	GSErrCode err = ACAPI_RegisterModelessWindow (
					GS::GenerateHashValue (paletteGuid),
					PaletteControlCallBack,
					API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation +
					API_PalEnabled_InteriorElevation + API_PalEnabled_3D + API_PalEnabled_Detail +
					API_PalEnabled_Worksheet + API_PalEnabled_Layout + API_PalEnabled_DocumentFrom3D,
					GSGuid2APIGuid (paletteGuid));

	...

	return err;
}
juliencuadra wrote:
- The API documentation only mentions palettes, not toolbars. Is it possible to create toolbars, also dockable like the archicad ones ?
Yes, it's possible.
Toolbar is a special palette. Toolbar is a fixed sized palette. So if you want to implement a dockable toolbar, then you should inherit your class from DG::Palette, use the base class constructor which has GS::Guid parameter and finally in your GRC assign a noGrow flag to your dialog.
Example GRC code:
'GDLG'  32500    Palette | topCaption | close | noGrow   0   0  450  150  "My Toolbar"  {
...
}

juliencuadra
Participant
Thank you tibor.

juliencuadra
Participant
Thanks to Tibor I got my toolbar to work and dock nicely in the archicad interface.

I have a followup question:

When I restart archicad, the toolbar is not displayed, I have to go in the menu to activate it. It then reappears at the location it was before.
I tried saving my archicad environnement with the toolbar showing but that did not fix the problem.

Is it possible to have an addon toolbar displayed at startup ?

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!