SOLIDWORKS PDM Hyperlinks to your Clipboard - In Plain Text!

Article by Jeff Sweeney on Aug 07, 2020

In 2018, SOLIDWORKS allowed users to copy a PDM file’s hyperlink to the clipboard. However, even though the Copy Link function is still available on a file’s context-sensitive menu, no mention of it can be found in the 2020 help file.

The ability to create SOLIDWORKS PDM Pro hyperlinks to files and folders has been around for many years. Hyperlinks are a great tool for opening, finding, and viewing documents from external sources. The problem has always been that the hyperlinks are not very easy to create. Before 2018, your only choices were to use the programming interface or build the link through SQL.

The idea with Copy Link is that you right-click on a file, click Copy Link, and that adds the hyperlink to your clipboard. Later, when you paste the link into an HTML-aware editor (e.g., MS Office), you’re pasting the name of the file into your document with the hyperlink properly added. The problem is that you cannot paste the link into non-HTML-aware locations. Notepad, your ERP system, database fields -practically everywhere else, the paste function doesn’t work.

I believe most of the time it would be better to have the hyperlink added to the clipboard as plain text. If it’s in plain text you can do anything you want with it. For a long time, I was doing this with a PDM add-in. It worked great, but writing add-ins isn’t for everyone. So, this blog post shows how I figured out a way to make a PDM data card button copy my hyperlinks to my clipboard for me.

How it Works – Behind the Scenes

[Warning: In this section, I get into some code writing. You don’t really need to know any of this to make it work in your data cards. If you just want to make it work, skip to the next section.]

The trick is to make the data card button run some PowerShell code to copy PDM hyperlinks to your clipboard.

SOLIDWORKS PDM Clipboard Hyperlinks Tutorial

No, I don’t normally use such terrible variable names. But card buttons will only accept 255 characters, so I purposefully made this code as tight as possible.)

  • Line two connects the code to the vault. The %2 is the data card parameter for the vault name.
  • I admit the third line is a hack, but it is the easiest way I have figured out how to define the folder object required in line four. If you know of a better way, please let me know!
  • Notice the %1 in line four. It’s the parameter sent by the data card button for the file’s full path. By reference “GetFileFromPath” also returns the actual folder, overwriting my hack from line three.
  • Lines five and six make getting the file and folder’s UID easy in building the hyperlink.
  • Line seven is where the rubber hits the road, and it writes the string in text format to the clipboard. Depending on the goal of the hyperlink, substitute the word explore for ‘open’, ‘view’, ‘get’, ‘lock’, ‘properties’, or ‘history’.

To take this code and put it into a card button, combine all seven lines into one and separate them with semicolons. Then, tell the command button you want to run the code with PowerShell by putting the word “PowerShell.exe” at the beginning of the line and put all of the code inside of double quotes.

Implementation

Now, let’s put this into action. First, add a button to your PDM Pro data card. Give the button a clever caption, set the command type to “Command String”, and cut/paste the code below into the data card’s “Command” property. Then, you can copy your PDM hyperlinks to your clipboard as often as your heart desires.

powershell.exe "$v=New-Object -COMObject ConisioLib.EdmVault;$v.LoginAuto('%2',0);$fo=$v.RootFolder;$f=$v.GetFileFromPath('%1',[ref]$fo);$fi=$f.id;$foi=$fo.id;Set-Clipboard -Value \"conisio://%2/explore?projectid=$foi&documentid=$fi&objecttype=1\""

The button properties should look like this:

SOLIDWORKS PDM Hyperlinks to your Clipboard - In Plain Text!

One last point: You need to check-in the file at least once for the hyperlink to be built properly.

Sorry PDM Standard users, this method uses API so it will not work for you.

Related Articles

SOLIDWORKS PDM 2025 - What's New

Configuration Properties in SOLIDWORKS PDM Data Cards

How to Create Dynamic Lists in SOLIDWORKS PDM Standard Data Cards

SOLIDWORKS PDM - Implement Working Revisions

How to Hide a Variable in a SOLIDWORKS PDM Data Card, But Keep it Searchable

VIEW ALL SOLIDWORKS PDM ARTICLES

 

About Jeff Sweeney

Jeff Sweeney is a SOLIDWORKS Data Management Product Manager at GoEngineer.

View all posts by Jeff Sweeney