US$0.00
0

SOLIDWORKS PDM API Tip: Using IEdmDictionary5 for Secure and Flexible Settings Storage in SOLIDWORKS PDM

Using IEdmDictionary5 for Secure and Flexible Settings Storage in SOLIDWORKS PDM gives developers a reliable and safe way to store and retrieve configuration data inside the vault. The IEdmDictionary interface in the SOLIDWORKS PDM API allows you to manage settings that can be specific to an add-in or a user, while keeping everything protected through the vault’s login system. This approach removes the need for external files and ensures your data stays both organized and secure.

Using IEdmDictionary5 for Secure and Flexible Settings Storage in SOLIDWORKS PDM and A promotional image with a blue background featuring a light bulb and a graduation cap at the top, symbolizing learning. The text "TIPS & TRICKS TO MASTER THE SOLIDWORKS PDM API" is prominently displayed, with "SOLIDWORKS" and "PDM API" in large white letters. A circular arrow icon is centered below the title. On the left, a red megaphone highlights a list of benefits: "50 TIPS & TRICKS," "PDM API CODE EXAMPLES IN C# / VB.NET," "SAVE HOURS OF RESEARCH & DEBUGGING," and "BECOME A BETTER API DEVELOPER.

Advantages

  • Secure Storage: Data is tied to the PDM vault and secured by the user’s login credentials.
  • Add-In-Specific Settings: Use a unique key to isolate settings for your add-in.
  • User-Specific Settings: Make settings unique to each user by appending the username to the key.  
/// Get the vault object and dictionary
IEdmVault5 vault = /* Get your vault object */;
IEdmDictionary5 dictionary = vault.GetDictionary("MyAddInDictionary", true);

// Serialize your settings to a JSON string
string jsonSettings = JsonConvert.SerializeObject(new { Theme = "Dark", AutoSaveInterval = 10 });

// Use a key to identify the setting
string addInKey = "MyAddIn_Settings";

// Store the serialized JSON string in the dictionary
dictionary.StringSetAt(addInKey, jsonSettings);

Retrieving Settings

To retrieve the stored settings, use the StringGetAt method:

// Retrieve the JSON string from the dictionary
string retrievedJsonSettings;
dictionary.StringGetAt(addInKey, out retrievedJsonSettings) 
// Deserialize the JSON string back into an object
var settings = JsonConvert.DeserializeObject<dynamic>(retrievedJsonSettings);

User-Specific Settings

You can create user-specific settings by appending the username to the dictionary key:

string userSpecificKey = $"MyAddIn_Settings_{vault.CurrentUser.Name}";
dictionary.StringSetAt(userSpecificKey, jsonSettings);

Best Practices

  • Use Descriptive Keys: Clearly define your dictionary keys to avoid conflicts.
  • Validate Data: Ensure your JSON strings are valid before storing them.
  • Avoid Excessive Use: Reserve the dictionary store for data that needs to be secure or specific to the PDM environment.
  • Secure Storage: Data is tied to the PDM vault and secured by the user’s login credentials.
  • Add-In-Specific Settings: Use a unique key to isolate settings for your add-in.
  • User-Specific Settings: Make settings unique to each user by appending the username to the key.

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop