10 Replies Latest reply on Feb 21, 2012 4:21 PM by Ty Toney

    Having serial numbers start at zero for each project

    Ty Toney

      Is there a way to have serial number counters linked to projects via variables or other? We would like it to where when we start a new project that the first part in the project has a serial of 0001, but also if we need to add to a previous project at a later date that the counter remains in tact for that project. I thought of creating a new serial for each project, but how do I link the project dropdown to a list of serial numbers?

        • Re: Having serial numbers start at zero for each project
          Jeff Sweeney

          If you wanted to create a serial number for each project, you would need to also have a unique datacard for each project so the datacard would know which serial number to use.

           

          Wouldn't be too painful if you only has a few new projects a year, just do a "SaveAs" on the card and save it into the new project.

           

          If you have many new projects and maintaining all of the serial numbers and cards sounds difficult, create a custom application would be the way I would go.

            • Re: Having serial numbers start at zero for each project
              Robert White

              Besides the example in the EPDM API docs, is there anything that specificly addresses this that is available to the public/subscription customers? It seems like a lot of people have run into this issue.

               

              Thanks!

                • Re: Having serial numbers start at zero for each project
                  Ty Toney

                  Robert,

                  Can you post a link to where you found this example? This has been an ongoing issue for us. All we want is the ability to select which serial number to use by a droplist of projects. Creating a new serial number set for each project would be no big deal but without the ability to select, we would have to create a new card and template too as a workaround. If we needed to revisit a previous project and make changes we'd have to change back to the old cards/templates. If we have too many templates available someone might pick the wrong one, it gets messy.

                    • Re: Having serial numbers start at zero for each project
                      Ty Toney

                      In working with a support tech from Hawkridge, we have devised a way to do this task. Files are named via the folder that they are placed into. It has a bug that needs worked out though. Being that it's a holiday today (president's day) Hawkridge is closed, they had only been involved in the theory and don't yet know of recent events.

                       

                      What I have done is to put a file card template in each sub-project folder with that folder's serial number attached to the variable "Number". I created a dispatch script to rename on add with a file path of %\%.sldasm as we only want our assemblies named by the project and sub-project. The rename scripting uses a "Path to selected file" in the "Path to file to rename" field and the variable "Number" in the new filename path. For the serial numbers the schema is as follows: "Project Code"-"Sub-project Code"-[Counter-04].sldasm. It looks like this X#-####-####.sldasm, the last 4 digits being the serial counter. I had to put the file extension on the serial to re-add during the rename. I tried putting it in the rename, in the Number variable and other places to get it to register, the serial is the only place it worked. With this setup it does rename the file with the correct serial counter and format.

                       

                      The Bug: For some reason the counter is malfunctioning and double or triple incrementing (i.e. the last 4 digits go from 0001-0003).

                       

                      Any ideas on why it's doing this. For anyone interested in this method of file naming, I can post some screens of what I did.

                       

                      Thanks,

                      Ty

                        • Re: Having serial numbers start at zero for each project
                          Ty Toney

                          I think I have found where the problem is occurring.Number increment problem.PNG

                          It appears after it renames the file from the serial number it increments it.

                            • Re: Having serial numbers start at zero for each project
                              Robert White

                              Ty, I want to thank you for providing the extent of information you have.

                               

                              I've encountered this double/triple-counting issue before and it is typically due to pulling the serial multiple times due to seperate operations acting together.

                               

                              On your file card, you may want to take out the association with the serial and leave it to report the 'Number' variable as text. In my ECO process, this fixed it.

                               

                              My question is this: when you're working in multiple projects, are the values unique? For Example:  If you're in project X2 and you add a file that becomes X2-####-0003, then you add the first file to project M4-####, will this file be -0004 or -0001?

                               

                               

                              Thanks!

                                • Re: Having serial numbers start at zero for each project
                                  Ty Toney

                                  Robert,

                                  The goal would be that the counter for the first file in a given folder be -0001. The way it's configured right now it even starts at -0001 in a sub project. Example: project X1, sub project 0200. The first assembly file to enter this sub-project folder would have a serial of X1-0200-0001. Now a file is placed in the 0300 sub-project folder, it becomes X1-0300-0001. They are still unique identifiers as the project and sub-project numbers have become part of the serial. What I have done is to have a serial number that is specific to each sub-project within a project (named X1-0100, X1-0200, etc.). The sub-project number is a set, consistant, division of the project by type. 0100 is always the main structure, 0300 is always the electrical system. We only number the assemblies like this, parts are just a straight 6-digit serial due to global project usage.

                                   

                                  As for the bug, I've tried many ways of how to associate the variable and serial to isolate it. No luck yet, but I will probably be hearing from Hawkridge soon. I'll post more details when we come up with a final solution.

                                   

                                  My next step in all this will be to come up with a New Project Template to try to automate the creation of the folders, cards, and serials to try to cut down excess administration.

                                  Ty

                                    • Re: Having serial numbers start at zero for each project
                                      Robert White

                                      Ty,

                                       

                                      Thank you for explaining. Just to check my understanding, this means that you have Serial Number Generator for each Project and sub-project? For Example in the EPDM Admin under Serial Numbers, you will have 'X1-0100', 'X1-0200', 'X2-0100', etc..

                                       

                                      or

                                       

                                      Do you have one generator setup with "Project Code"-"Sub-project Code"-[Counter-04] where "Project Code" and "Sub-Project Code" are variables?

                                       

                                      Thank you,

                                      Robert

                                        • Re: Having serial numbers start at zero for each project
                                          Ty Toney

                                          Robert,

                                          No variables, I have a generator for each sub-project that is project specific (X1-0100, X1-0200, X2-0100, etc.). All I did is typed the project & sub project code numbers in before the counter and the file extension after it. For some reason it loses the extension during the rename and is just a File. Putting in the extension fixed that. When I post the final outcome I will have several pics so it is clear.

                                          Ty

                                            • Re: Having serial numbers start at zero for each project
                                              Ty Toney

                                              The bug is now fixed!! I was looking for something more complex than what it was. The checkbox for Update All Configurations must be checked. What happened was the @ config was assigned one serial number and the default config was assigned a second. The tech from Hawkridge and I streamlined a few things. Now for the picsfile template card Number selected.PNG

                                              The file template card. Named for the folder it goes into and is the same name as the serial generator. The Number variable is selected here.

                                              file template card serial selected.PNG

                                              Same card with the Serial Number variable selected.

                                              rename dispatch script.PNG

                                              The Dispatch script for renaming the file.

                                              rename dispatch conditions.PNG

                                              The conditions to trigger the operation.

                                              rename dispatch file path.PNG

                                              The file paths in the file rename function of the script

                                              rename dispatch variables.PNG

                                              Last but not least is the user variables for the script.

                                               

                                              I hope this helps for anyone else attempting this. As a recap, to have files named by the folders they are placed into you need to do the following: Create serial number generators for each applicable folder, create a file card template for each folder, connect a variable on the template to the corresponding serial generator, write a dispatch to rename.

                                               

                                              SolidWorks does something kinda funny when you do a save as operation directly into the vault. The file that SW has open will retain the Assem4 filename and be changed to a read only. To continue working on the file you must close the read only file and open the renamed file. I assume it does this cause you have the file open still when it renames. Saving to your local drive, then moving the file into the vault will rename just the same but you won't see the read only file since you won't have it open. Good Luck all!

                                              Ty