Data cards that configure themselves

Various tools in PDM can make data cards configure themselves based on the file behind it.

One of the standout features of SolidWorks PDM is the use of data cards, which play a pivotal role in capturing and displaying crucial information associated with vault files.

Data cards are not a new concept for SolidWorks PDM users. They have been instrumental in organizing metadata, providing visibility into file properties, and ensuring that essential details are never overlooked. However, in this article, we will explore an approach that takes data cards to a whole new level.

Data cards that dynamically adapt to the type of file you're working with, showing you precisely the information you need, precisely when you need it. Picture a scenario where the data card becomes an intelligent companion, responding to a characteristic of the file itself, its file extension. Often in PDM vaults we have a directory of support files that are used in various vault process, PDM templates for example or maybe some simple text files, or stored SQL query.

Each of these files has a particular file extension, .docx, .txt, .sql, etc. The cornerstone of this approach lies in three tools coming together in PDM, all three are simple and easy to incorporate within a vault. The first step is to create a variable called "File Extension". This hidden field on a data card captures the extension of each file, recording its unique file extension and is updated automatically the moment a file is added to the vault. How does this happen? Thanks to a vigilant PDM Dispatch routine that continuously monitors a directory and potentially all its sub-directories, springs into action as soon as new files are added there.

But what truly sets this approach apart is the synergy between the "File Extension" variable and the third aspect of this approach, the tabbed interface control on a data card. No more static displays of information that remain the same regardless of the file type. Instead, the data card becomes a dynamic entity, intelligently driven by the "File Extension" variable. When you select a file to view the data card, the data card reveals data fields that are pertinent to that specific file type because the tabbed interface for that extension is turned on by the value within the File Extension field.

First Step: Create a variable called File Extension.

Create a variable called File Extension, there is no need to create any block for it or attributes as we are not writing to the actual file, just the data card.

Second Step: Get the file extensions in your vault.

Getting all the file types in your vault is quite easy, but you will need to run a SQL query. You can either run it in SQL Server Mgt Studio or as .crp file using the Report Generator in PDM. Here is the SQL query that will get you the list:

SELECT UPPER(Extension) as 'Extensions'
FROM FileExtension 
WHERE Extension NOT LIKE '%,%' 
 AND Extension NOT LIKE '%.%'
 AND Extension <> ''
 AND Extension NOT LIKE '%<%>%'
 AND Extension NOT LIKE '*'

Once you have the list of file extensions open the data card and activate the tabbed interface so you can apply the names. Paste in the list into the Tab names field.

Now you have a list of file extensions as tab names. Next add drop down as shown and set it to capture the File Extension variable. This field will ultimately be hidden on the data card. Now we need to assign the card all the extensions it will handle. The same extension list applies here and we just need to put a semicolon between each one. Use Word to do this with the Find/Replace of the carriage return to a semicolon and then paste the list into the cards File extensions field. Save the card to the directory(s) it will be applied to. I use this card for the Common files directory, where files may vary widely and need slightly different field data captured.

Open any image in new tab to make clearer.

Step 3: Automating the capture of the files extension.

Dispatch is the poor-mans macro tool in PDM. It has lots of useful features and this is what is used to capture the file extension to the data card.

Create a new Dispatch routine and define the user variables as shown.

This shows the overall Dispatch routine and process order.

Here are all the functions to extract the file extension from any file.

This shows how the Dispatch is triggered (During add selection) and then which directory and subdirectories to apply the Dispatch to. This gets all the subdirectories in the Common folder.

Now add a file to any subdirectory of the path in the Dispatch and it should add the files extension to field. The card will then display the tab for that file type. You can add different fields to each tab that provide the needed information for that file type.

Once you have verified that the field is filling correctly you can then shrink the field on the card and place it at the margin of the card and shrink the cards outline to hide it.

Previous
Previous

What’s in a name?

Next
Next

Leveraging Multi-Role Excel Design Tables in SolidWorks