SimConnect register the custom property

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Post Reply
pine-nut
Posts: 7
Joined: Sat May 27, 2023 10:07 am

SimConnect register the custom property

Post by pine-nut »

Based on example: https://www.prepar3d.com/SDKv5/sdk/simc ... _data.html
add code:
......
Struct.YourCustomValue = 1000.0;
hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_STRUCT, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(Struct), &Struct);
......
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_STRUCT, "YourCustomValue", "Number", SIMCONNECT_DATATYPE_FLOAT64, 20.0, SIMCONNECT_UNUSED);
......

But press the keyboard: Ctrl+Shift+B, The SimConnect Diagnostic Output will report an error: "EXCEPTION=20" !!!

Is the SimConnect unable to register the custom property like the ISimObjects ?
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: SimConnect register the custom property

Post by Clifton Crane »

Hello pine-nut,

SimConnect cannot be used to register a new custom property. This would need to be done via RegisterProperty calls.

Once registered, you should be able to use the functions you mentioned above to get/set data, similar to native simulation variables.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
Post Reply