US$0.00
0

Category: SOLIDWORKS

Automate Weekly SOLIDWORKS PDM Check-Ins with PDMShell and Windows Task Scheduler

This article explains how to use PDMShell with Windows Task Scheduler to automatically check in files from a SOLIDWORKS PDM vault folder on a weekly schedule. PDMShell is a command-line tool for SOLIDWORKS PDM that allows administrator to run PDM operations from scripts. By combining PDMShell with Windows Task Scheduler, you can automate recurring PDM tasks such as logging in to a vault, navigating to a folder, searching for files, and checking in files. Before setting this up, make sure PDMShell is installed on the computer that will run the scheduled task. The computer must also have a local PDM vault view, and the Windows account running the task must have access to that vault view. The same user must also have permission to check in the files. In most SOLIDWORKS PDM environments, a user can only check in files that are checked out by that same user. If the files are checked out by another user, the scheduled task will not be able to check them in unless you have a controlled administrative process in place. Click on the Open button then click on Browse PDMShell.com scripts… Download the script called Check In All Files: When the download completes, please click Yes to confirm this dialog: PDMShell will load the downloaded script in the Visual Editor: If you click on the check-in box, you will the parameters of the command. In this instance, the command does a search for all checked out files recursively and check them into the vault. The check options configure the check-in operation.The script will eventually terminate the PDMShell application when done through the Exit PDMShell action: Before scheduling the script, test it manually from Command Prompt: Update the path to pdmcli.exe if PDMShell is installed in a different location. Once the script works manually, open Windows Task Scheduler and create a new task. On the General tab, use a name such as: Select the option to run whether the user is logged on or not. Also enable the option to run with highest privileges. The task should run under the same Windows account that has access to the vault view and owns the checked-out files. On the Triggers tab, create a weekly trigger. For example, you can run the task every Friday at 6:00 PM. On the Actions tab, create a new action using Start a program. Program/script: Add arguments: Start in: On the Conditions tab, review the power and network options. If the task runs on a workstation, make sure the machine is online and connected to the PDM archive server when the task starts. On the Settings tab, it is recommended to allow the task to be run on demand, run the task as soon as possible after a scheduled start is missed, stop the task if it runs longer than a reasonable time, and prevent a new instance from starting if the task is already running. For production usage, keep the script focused on a controlled folder instead of running it against the entire vault. For example: PDMShell and Windows Task Scheduler provide a simple way to automate recurring SOLIDWORKS PDM maintenance tasks. For production environments, always test the script on a small folder first and make sure the scheduled task runs under the correct Windows and PDM user. Few considerations:

Read More »

SOLIDWORKS Task Pane Icons: Fixing Transparency Issues

When creating a SOLIDWORKS task pane, the SOLIDWORKS API documentation says that icon transparency can be handled by using a specific background color. For CreateTaskpaneView3, the documentation explains that task pane bitmap images should use a 256-color palette, and that the transparent area should use the following color: The expectation is simple: wherever the icon uses that gray color, SOLIDWORKS should treat it as transparent. In practice, that does not always work. You may create the icon exactly as described, use the correct gray background color, and still see a gray box behind the icon inside SOLIDWORKS. The documentation suggests that this gray color should be treated as transparent. However, when the task pane loads, SOLIDWORKS may still display the gray background. This can make the task pane icon look unfinished or inconsistent with the rest of the SOLIDWORKS interface. This usually means the image background was not actually transparent. It was only colored gray, and SOLIDWORKS did not remove it during rendering. The Solution: I have not been able to verify this for older version of SOLIDWORKS. Instead of depending on SOLIDWORKS to interpret RGB(192, 192, 192) as transparent, remove the background from the image and save it as a PNG with real transparency. This gives SOLIDWORKS a cleaner image to work with and avoids the visible gray background issue. Use an image editor that supports real PNG transparency and layers. I highly suggest good old mspaint.exe. This works great if you are on Windows 11 with the AI-enabled MSPaint. The general process is: After saving, the background should be truly transparent instead of just colored gray in SOLIDWORKS.

Read More »

SOLIDWORKS API Memory Access Violations Caused by GDI Object Count and Unreleased COM Objects

When building long-running SOLIDWORKS API tools, crashes are not always caused by high RAM usage. One of the most common causes of instability is excessive GDI object usage combined with unreleased COM objects. This often appears during batch automation jobs where SOLIDWORKS repeatedly opens documents, makes them visible, generates previews, switches windows, or captures images. The most typical symptom is the “Memory access violation” exception which tends to crash SOLIDWORKS. In many cases, the real issue is that GDI objects are slowly accumulating until the process reaches the Windows limit. What Causes GDI Object Leaks? GDI objects are Windows resources used for UI rendering. They include: In the SOLIDWORKS API, GDI count can increase rapidly if you repeatedly: At the same time, COM references to SOLIDWORKS objects can remain alive longer than expected if they are not released manually. Common SOLIDWORKS COM objects that should be released include: Opening documents silently is usually much safer than opening them visibly. When a document is made visible, SOLIDWORKS creates additional windows, previews, feature manager graphics, graphics pipeline objects, and UI resources. For example: swApp.Visible = true;var model = swApp.OpenDoc6(path, type, options, “”, ref errors, ref warnings); If this occurs repeatedly inside a large loop without proper cleanup, the GDI count can climb rapidly. This is especially common when processing: How to Monitor GDI Object Count You can monitor GDI usage directly in Windows Task Manager: Watch the SLDWORKS.exe process while your code runs. If the GDI count keeps climbing and never comes back down, you likely have a leak. Once a process gets close to around 10,000 GDI objects, crashes and instability become much more likely. Best Practices to Avoid Crashes 1. Dispose Graphics Resources Always wrap GDI-related objects in using blocks: using (Bitmap bmp = new Bitmap(width, height))using (Graphics g = Graphics.FromImage(bmp)){ g.Clear(Color.White); // Draw content here bmp.Save(outputPath);} This applies to: 2. Close Documents Immediately Never leave documents open longer than necessary: ModelDoc2 model = null;try{ model = swApp.OpenDoc6(path, type, options, “”, ref errors, ref warnings); // Process document}finally{ if (model != null) { swApp.CloseDoc(model.GetTitle()); Marshal.ReleaseComObject(model); model = null; }} 3. Release COM Objects Aggressively SOLIDWORKS API objects often remain alive even after they go out of scope. Release them manually: if (feature != null){ Marshal.ReleaseComObject(feature); feature = null;}if (component != null){ Marshal.ReleaseComObject(component); component = null;} This is especially important in loops processing hundreds or thousands of components, features, faces, or bodies. 4. Periodically Force Garbage Collection For large batch operations, periodic garbage collection can help reduce memory pressure: GC.Collect();GC.WaitForPendingFinalizers();GC.Collect(); This should not replace proper disposal and COM cleanup, but it can help stabilize long-running jobs. 5. Prefer Silent Processing Whenever possible, process documents silently instead of visibly: int options = (int)swOpenDocOptions_e.swOpenDocOptions_Silent; This reduces UI overhead and significantly lowers GDI usage. Final Thoughts If your SOLIDWORKS API application crashes after running for a long time, do not assume the issue is only RAM usage. Monitor GDI objects, dispose of graphics resources, close documents immediately, and aggressively release COM references. These small changes can make a major difference in the stability of long-running SOLIDWORKS automation tools, especially when processing large assemblies, exporting files, or generating previews. For large PDM tasks, image generation, PDF export, or batch automation jobs, careful cleanup is often the difference between a stable application and one that crashes after a few hundred files.

Read More »

How to Safely Delete a Vault in SOLIDWORKS PDM (Step-by-Step)

Deleting a vault in SOLIDWORKS PDM is a destructive and irreversible operation. It removes the vault definition from the archive server and permanently deletes the associated database. This post walks through the correct order of operations, common prompts you’ll see, and the most frequent error that blocks vault removal.

Read More »

Automating Bill of Materials Extraction in SOLIDWORKS PDM Using the PDMShell BOM Command

Ride of the Valkyries Alert 🎼 — Don’t listen if you don’t enjoy Wagner. When you are managing complex assemblies inside SOLIDWORKS PDM, generating a bill of materials (BOM) is a routine task, but i’s also one of the most repetitive. This is exactly where the PDMShell BOM command becomes invaluable, eliminating manual exports and saving your from those small tasks quitely eat away engineering hours across large teams. PDMShell solves this problem with a simple but extremely powerful tool: the BOMCommand. The BOMCommand extracts a Bill of Materials directly from a SOLIDWORKS file in the PDM vault and exports it as a clean CSV file. It removes all manual steps by providing a scriptable way to generate BOMs using batch jobs, scheduled tasks, or command-line workflows. If you’ve ever needed fully automated downstream manufacturing data, ERP integrations, or repeatable export pipelines, this command is designed for exactly that.

Read More »

PowerShell PDMShell Search Command: Complete Guide for SOLIDWORKS PDM Administrators

PDMShell gives SOLIDWORKS PDM administrators the ability to run precise, scriptable, and automated operations across large sets of files, and the PowerShell PDMShell search command is at the center of that capability. One of its most powerful features is the unified search syntax unlocks a completely different level of control over your PDM vault. Consider the following search command: At first glance, it may appear complicated, but every element serves a clear purpose and is easy to understand once broken down. Name=%.sldprt This filter targets all part files (SLDPRT) using a wildcard pattern.The use of % allows flexible pattern matching, returning any file that ends with .sldprt regardless of prefix or naming convention. Recursive=true This instructs PDMShell to search not only the current folder, but all subfolders beneath it.This is especially important for large vaults, deep project structures, or multi-level assemblies. @Document Number~143 This uses a variable-based search.PDMShell looks up the PDM variable named “Document Number” and applies a contains (~) comparison against the value 143. Variable search supports all standard comparison operators, including equals, greater than, less than, contains, and more. What makes this system so powerful is that the same search filter can be passed into a wide range of PDMShell commands. You write the search once, and then apply it to whatever action you need to perform. Below are the PDMShell commands that fully support the -search parameter, along with direct documentation links: Version Control frogleap (increment, decrement, or manage versions)https://pdmshell.com/src/FROGLEAP.html Bulk Variable Updates setvar (update PDM variables in bulk)https://pdmshell.com/src/SETVAR.html File Removal delete (soft-delete matching files)https://pdmshell.com/src/DELETE.htmldestroy (permanently remove matching files)https://pdmshell.com/src/DESTORY.html Local Cache Retrieval get (retrieve files to local cache)https://pdmshell.com/src/GET.html Publishing and Exporting export (PDF, DXF, STEP, and custom publishing)https://pdmshell.com/src/export.html SOLIDWORKS Automation runswmacro (open SOLIDWORKS and execute a macro on each file)https://pdmshell.com/src/runswmacro.html File State Management checkouthttps://pdmshell.com/src/CHECKOUT.htmlcheckinhttps://pdmshell.com/src/CHECKIN.html If you would like more examples, additional documentation, or help building automated workflows, reach out anytime.

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