I was too vague, and I still don’t have all the correct names/terms at the top of my head. What you say is pretty much what I’m doing. Using SetValEx and GetValEx, but instead of having a bunch of them I just have one. I don’t have much real, guided, experience but I don’t like casting from System.object all the time. I think they call it strongly typed code, I prefer that, it’s just easier to read and follow. Anyway instead of having a bunch of values stored with string names (can can be defined as const, I know) and casting, I made a struct of the data I needed to store and decorated it Serializable() then store that string as the one and only user variable. This way when I deserialize the stored string all the types are there and I access them as Properties.
Just wondering if anyone else is using this method. What I have seems to be working, but frankly, I don’t know if I implemented it right or the best way.
The process is outlined in the Remarks of the SW PDM API Help:
http://help.solidworks.com/2019/english/api/epdmapi/epdm.interop.epdm~epdm.interop.epdm.iedmtaskproperties~getvalex.html?verRedirect=1
Remarks
Call IEdmTaskProperties::SetValEx to store variable data entered by the user in the task definition setup page on the client machine. The task definition setup page displays during the processing of the EdmCmdType.EdmCmd_TaskSetup hook when the task add-in calls IEdmAddIn5::OnCmd.
Custom data types and objects must have been serialized to a string, numeric type, or date before calling IEdmTaskProperites::SetValEx. For example:
Serialize the object data to XML or JSON using StringBuilder, XmlWriter, XmlSerializer, etc.
Call IEdmTaskProperites::SetValEx to store the resulting string.
Call IEdmTaskProperites::GetValEx to retrieve the stored string.
Initialize the new instance of the object from XML/JSON using StringReader, XmlReader, XmlSerializer, etc.
To get the values when the task is executing on the server, call IEdmTaskInstance::GetValEx during the processing of the EdmCmdType.EdmCmd_TaskRun hook.
NOTE: User-defined variables are not related to the card variables created using the administration tool. To access card variables for this task definition, call IEdmTaskProperties::GetVar and IEdmTaskProperties::SetVar.