5 Replies Latest reply on Jul 6, 2018 3:52 PM by Craig Schultz

    Map a files File Extension (file type) to a PDM Variable on File Card?

    Shawn Talley

      I am using SolidWorks PDM Professional and trying to get a file's file extension mapped to a PDM Data Card Variable on the File Data Card?  Basically I want to store the files file extension in a PDM Variable called FileType (for example, DWG --> FileType Variable).

       

      What I am trying to do is to use one data card for multiple file types that display similar info.  I am trying to do this currently with the "Controlled by Variable" option on a Tab Control.  What I want to do is have one tab for a DXF file, another for a DWG file, and so on...  I could also use this on SolidWorks files, where one tab would be for a Part file (SLDPRT), one for an Assembly File (SLDASM), and one for a Drawing file (SLDDRW)...

       

      I just cannot seem to get the file type portion of the file name into a PDM Variable to use for controlling the tabs.  I have tried Input Formulas on a variable, but since they require some form of manual input on a data card to run or calculate, it fails to work...  This seems like an easy string manipulation problem, but I just must be missing something simple I hope...

       

      Thanks in advance,

      Shawn

        • Re: Map a files File Extension (file type) to a PDM Variable on File Card?
          Steve Ostrovsky

          So my first question would be "Do these different file types have uniquely different variables that you need manage?" Meaning, if you have Part Number, Description, Material, Weight, Finish, Created By, Approved By, etc. that are all used for all engineering CAD file types, what variables are unique to each file type. If you have a list for each then I could see handling your document types this way.

           

          You can capture the file name+ extension on one variable and then use an input formula - $Right(%FileName%,3) - for your file extension. The problem is going to come when you try to get the SolidWorks 6 character extension when DWG and DXF are 3 characters.

           

          You could possibly do all of this through Dispatch, but I'm too busy to go test it out.

            • Re: Map a files File Extension (file type) to a PDM Variable on File Card?
              Shawn Talley

              Steve, I do indeed have a list for each individual unique variable for each file type.  There are some other data cards and file types I was thinking about using this method for as well.  The example I gave earlier (dxf's/dwg's) was one such case...  Anyhow, I was trying to do basically what you listed in the input formula, however I statrted by first doing the following:  $FindReverse(%FileName%, .) to search in reverse for the last "." in the file name, then used that as input (the count) to subtract off the total length of the file name to determine the exact file extension...  That probably did not make much sense, but this is basically the input formula I was using:  $Right(%FileName%,$Sub($Len(%FileName%),$FindReverse(%FileName%,.))).

               

              However when I do that, the field on the data card just stays blank, and I'm not getting any reported errors...  I am actually uncertain if the FindReverse will locate the period character correctly?  I even tried it in quotes "." and didn't get anything either...

            • Re: Map a files File Extension (file type) to a PDM Variable on File Card?
              Craig Schultz

              If your formula doesn't work, here's another possible solution.

               

              From you initial state you could have the files go through an automatic transition based on the file extension.  During the transition, it would populate the variable with your extension.

               

              That would allow you to push similar files (i.e. DWG and DXF or png, bmp, jpeg) through the same tranistion and get populated with the same value..."2D CAD" "Image FILE".  That way you wouldn't need a tab for every extension on your data card.