US$0.00
0

Category: PDM API Tips

SOLIDWORKS PDM TIP: Creating Submenus in SOLIDWORKS PDM with IEdmCmdMgr5::AddCmd

If you’re developing custom add-ins or commands for SOLIDWORKS PDM, you may want to improve the user experience by organizing your commands into submenus. This approach is central to creating submenus in SOLIDWORKS PDM, ensuring a more professional and structured interface. As you add more commands, a cluttered context menu can quickly become overwhelming, so grouping related commands under a parent label keeps the interface clean and intuitive. How to Create a Submenu To create a submenu, use the double backslash (\\ in C# if not escaped) separator in the menu name when registering your command with AddCmd. Example poCmdMgr.AddCmd(15065, “ParentMenu\\ChildMenu”, 43, string.Empty, string.Empty, -1, 0); This code registers a new command under: Right-click > ParentMenu > ChildMenu Important Notes Need help building PDM tools or structuring your add-ins? Reach out to Blue Byte Systems Inc. — we specialize in SOLIDWORKS PDM automation and custom development.

Read More »

SOLIDWORKS PDM API Tip 16: Why IEdmFile5::IsLocked Requires a Call to Refresh()

When working with the SOLIDWORKS PDM API, it’s important to understand how the system handles state and caching. One frequently misunderstood property is IEdmFile5::IsLocked. Understanding why IEdmFile5::IsLocked requires a call to refresh() is crucial, as while it appears straightforward, it doesn’t behave like properties in reactive UI frameworks such as WPF, and this can lead to subtle but critical issues in automation and add-in development. Understanding CLR Properties in the PDM API In environments like WPF, dependency properties offer real-time synchronization with the underlying data model. Any change is automatically reflected in the property value. This is not the case with the PDM API. Properties like IEdmFile5::IsLocked are standard CLR properties. These properties do not auto-update when changes occur in the vault. Instead, they rely on cached data at the time the IEdmFile5 object was retrieved or last refreshed. What This Means for Developers IsLocked will not reflect the actual current lock state of a file if that state has changed since the last time the file object was refreshed. This commonly occurs in scenarios such as: In these cases, reading the IsLocked property without refreshing the object will return outdated information. Correct Usage To ensure you’re working with current data, always call IEdmFile5::Refresh() before accessing lock-related properties: This forces the object to synchronize with the current state of the vault, ensuring IsLocked reflects the latest status. When to Use Refresh() Besides IsLocked, other properties that depend on current vault state also benefit from a refresh call: In general, any time you suspect that external operations may have changed the state of a file, refreshing before reading is a safe and recommended approach. Conclusion The SOLIDWORKS PDM API does not use reactive or event-driven state tracking. It’s up to the developer to ensure that objects are up to date before relying on their state. Understanding why IEdmFile5::IsLocked requires a call to refresh() helps developers prevent inconsistent behavior and significantly reduce debugging time in complex workflows or automation scenarios.

Read More »

SOLIDWORKS PDM API: Optimizing Large Scale Operations with Batch Interfaces in SOLIDWORKS PDM

When making numerous calls to the same operation in SOLIDWORKS PDM, the batch interfaces (e.g., IEdmBatchAdd2, IEdmBatchChangeState5) are designed to maximize efficiency and performance. Optimizing large scale operations with batch interfaces in SOLIDWORKS PDM becomes essential when handling high file volumes, helping reduce processing time and system strain while maintaining reliable automation. Here’s a list of all the batch interfaces in PDM and their intended uses. Interface Description IEdmBatchAdd2 Allows adding multiple files or folders to the vault with improved support for additional options. IEdmBatchChangeState5 Enables batch transitioning of files to a different workflow state with the most advanced features. IEdmBatchDelete3 Provides functionality for deleting multiple files from the vault with enhanced validation. IEdmBatchItemGeneration2 Facilitates batch generation of items, ensuring efficient handling of linked item creation. IEdmBatchListing4 Retrieves detailed lists of files, folders, or items in the vault with extended filtering options. IEdmBatchUnlock2 Check-in operation for multiple files in a batch, including support for conditional operations and error handling. IEdmBatchUpdate2 Updates properties or variables for multiple files in the vault with better performance and reliability. You may also read: SolidWorks Macro to Batch Rebuild and Export Drawings to PDF

Read More »

SOLIDWORKS PDM API TIP: Stop Using File Names in PDM Automation – Here’s Why IDs Are Better

When developing automation tools or add-ins for SOLIDWORKS PDM, one of the most common mistakes I see is relying on file paths or names to identify objects. Stop using file names in PDM automation because, at first glance, it seems logical—after all, files have names, right? But here’s the problem: file names and paths are fragile. Users can (and will) rename files, move folders, or reorganize entire directories. The moment that happens, your automation breaks. Enter Immutable IDs SOLIDWORKS PDM assigns a unique, immutable ID to every object—files, folders, data cards, you name it. These IDs never change, no matter what the user does. By using these IDs in your scripts and add-ins: Real-World Example Let’s say your script updates a custom property on all files in a certain folder. If you use the folder path and someone moves it, your script won’t find it. If you use the folder’s ID, it works no matter where it lives. The Takeaway Best practice: Always use IDs to identify objects in SOLIDWORKS PDM. Paths and names are for humans. IDs are for automation.

Read More »

SOLIDWORKS PDM API TIP: Writing Add-ins with Version-Specific APIs

When writing an add-in for SOLIDWORKS PDM, it is essential to consider compatibility across different versions of the software. Some API calls introduced in newer versions may not be available in older versions, potentially causing runtime errors for clients using older systems, which is why writing add-ins with version-specific APIs becomes so important. Scenario Suppose your add-in uses an API feature introduced in SOLIDWORKS PDM 2022, but some clients are still using SOLIDWORKS PDM 2018. To ensure compatibility, you can programmatically check the PDM version installed on the client’s machine before calling the new API. Solution: Use the GetVersion Method The GetVersion method allows you to retrieve the major and minor version numbers of the installed SOLIDWORKS PDM Professional. Based on the version, your code can decide whether to execute the new API call or fall back to an alternative logic for older versions. Implementation Here is an example in Visual Basic: This approach ensures your add-in remains robust and user-friendly, even in environments with mixed PDM versions, highlighting the importance of writing add-ins with version-specific APIs.

Read More »

SOLIDWORKS PDM API Tip: Ideal Number of Add-ins Per SOLIDWORKS PDM Vault

Your add-ins consist of DLL files. Each time an application like explorer.exe logs into PDM, it loads those files into the application’s sessions, increasing startup time and memory usage. While memory use is not a major issue these days, startup time can be noticeably affected. This is why it’s essential to ideal number of add-ins per SOLIDWORKS PDM vault, as having too many add-ins can significantly impact user performance and responsiveness. The ideal number of add-ins is five, but PDM already includes three default ones: This means you only have 2 slots left for custom add-ins before performance starts to degrade. Each add-in adds overhead, increasing vault load times. Instead of multiple separate add-ins, merge functionalities into one to keep performance smooth. ✅ PDM already has 3 built-in add-ins, leaving space for just 2 custom add-ins.✅ Too many add-ins slow down vault operations.✅ Merging multiple add-ins into one improves performance & simplifies maintenance.

Read More »
0
    0
    Your Cart
    Your cart is emptyReturn to Shop