We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

More settings fun

TomWaltz
Participant
I am trying to get our Section Tool to default to a few things, like "Use element colors" and "Show on stories partially in range."

The story part works, the Use Element Colors does not, and I am getting the "No error encountered" response in the Report window, so I know the right loop is running, but nothing seems to be happening. This same structure is working for almost every other tool in the toolbox....

Yes, I know the reporting code is ugly, but I usually just copy/paste it in as needed to help me chase problems....
void  KA_SetSection()
	{
		API_Element    			element, mask;
		GSErrCode       		err;

		BNZeroMemory (&element, sizeof (API_Element));

		element.header.typeID = API_CutPlaneID;
		err = ACAPI_Element_GetDefaults (&element, 0);
		if (err == NoError) 
			{
				ACAPI_ELEMENT_MASK_CLEAR (mask); 
				
				ACAPI_ELEMENT_MASK_SET (mask, API_CutPlaneType, markerSize);
				ACAPI_ELEMENT_MASK_SET (mask, API_CutPlaneType, textSize);
				ACAPI_ELEMENT_MASK_SET (mask, API_CutPlaneType, useElemPens);
				ACAPI_ELEMENT_MASK_SET (mask, API_CutPlaneType, cutPlShow);

				element.cutPlane.markerSize = 10.578278;			// 30 points, in mm
				element.cutPlane.textSize = 2.644569; 				// 7.50 points, in mm
				element.cutPlane.useElemPens = true;
				element.cutPlane.cutPlShow = APICutPl_ShowPartRange;
				
				ACAPI_Element_ChangeDefaults (&element, NULL, &mask);
					char    elemStr[32];
				    char    msgStr[256];

					CHCopyC ("No Error", elemStr);		
					sprintf (msgStr, "%s Encountered", elemStr);
				    ACAPI_WriteReport (msgStr, false);
			}
			else
				{
					char    elemStr[32];
				    char    msgStr[256];

					CHCopyC ("Error", elemStr);		
					sprintf (msgStr, "%s Encountered", elemStr);
				    ACAPI_WriteReport (msgStr, false);

				}
		return;
	}
Any suggestions would be greatly appreciated.
Tom Waltz
3 REPLIES 3
Oleg
Expert
I think the useElemPens field is for "Use Cut Element's Own Pencolors" in the Cut Elements rolldown panel. I didn try it on AC9, but it seem works on AC81.

If you mean "Use Symbol Colors" checkbox in the Marker rolldown panel, I think you need use GetDefaultEx and ChangeDefaultEx. I guess it is a marker field ( like useObjPens of ObjectType ), so you will need set the elementMarker and maskMarker parameters of the ChangeDefaultEx function.

But I didnt try it, just guessing.
TomWaltz
Participant
Thanks, Oleg, I'll give that a shot!
Tom Waltz
TomWaltz
Participant
In playing with this a bit, it seems as though the API_CutPlaneType structure definition does not include any of the settings in the "Marker" pane of the Section Tool Settings menu, including which marker object to use, font size, and pen color.

I've been messing around with the GetDefaultEx functions, but they only seem to apply to a selected element, not setting the defaults of a selected tool (unless I misread that).
Tom Waltz