License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

GSHandle to structure [SOLVED]

ReignBough
Enthusiast
I have a structure and I saved it on attribute user data using:

API_AttributeUserData user_data;
user_data.dataVersion = MY_ATTS_VERS;
user_data.platformSign = GS::Win_Platform_Sign;
user_data.dataHdl = BMAllocateHandle(sizeof(MyUserData), ALLOCATE_CLEAR, 0);
GSErr ud_err = BMPtrToHandle(&UserData, &user_data.dataHdl, sizeof(MyUserData));
ACAPI_Attribute_SetUserData(&UDHead, &user_data);
UserData is the user data to be saved, and UDHead has the typeID and index.

When I use ACAPI_Attribute_GetUserData(), I am able to get the version and platform sign. But I am lost in retrieving the saved user data.

Help anyone?

>> ArchiCAD 17
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
2 REPLIES 2
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi,

I think it should work this way:
err = ACAPI_Attribute_GetUserData (&attribute.header, &userData); 
if (err == NoError) { 
	MyUserData** myUserData = reinterpret_cast<MyUserData**> userData.dataHdl; 
	// now you can use the userdata 
	// after working with it, don't forget to free the handle! 
	BMKillHandle (&(userData.dataHdl)); 
} else { 
	ACAPI_WriteReport ("Error: ACAPI_Attribute_GetUserData", false); 
}


Regards,
Tibor
ReignBough
Enthusiast
Thanks Tibor.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS