5 Replies Latest reply on Feb 15, 2013 3:19 PM by Daen Hendrickson

    Extract the first five characters of custom property to BOM

    Kevin Goosie

      I have tried searching, somewhat quickly and not very in depth, to see if there is a solution to only show the first five characters from a custom property in a BOM column. I want to add a note to the cage code, 01365 - USMC, in the custom property field, but only want to display the first five characters in the BOM, 01365. Does anyone know how to do this, or is there any documentation on what equations can be placed in the BOM using the equations command, and are there any "hidden" commands that will work?

        • Re: Extract the first five characters of custom property to BOM
          Patrick O'Hern

          I can't think of any way to do what you are asking for, but could you not just add your note to its own custom property?

          • Re: Extract the first five characters of custom property to BOM
            Deepak Gupta

            Create a new property and then using equations or vba script in the file properties for part to show the required digits and then call that property in BOM.







            • Re: Extract the first five characters of custom property to BOM
              Daen Hendrickson



              Here is a methodology that might do what you want. Thanks to Josh Brady for presenting this approach.


              You can add some VB commands into equations to manipulate custom properties. When you rebuild the file the equations will be recalculated and cause the VB to run. Your profile says you are running SW2009. In SW2012 they changed the equation editor and a few more steps are required. You can skip those.


              Create two custom properties in your file for Cage Code With Description and Cage Code for BOM. You can name them whatever you want. I used:


              CageCodeWithDesc     set to 01365 - USMC

              CageCodeBOM            set to nothing


              Next you need to create an equation (Tools, Equations). The name of the variable in the left column is irrelevant - set it to Var1 or CageCodeVB. Paste the following for the equation:




              The equation will evaluate to a -1. That's expected. Exit and rebuild your part file. The custom property for CageCodeBOM should be filled in with the LEFT 5 characters of the value in CageCodeWithDesc.


              This equation gets the value of CageCodeWithDesc, takes the left 5 characters, and sets the value of CageCodeBOM to those characters.


              If you use differently named custom properties, you will need to make some edits to the equation. Notice that the custom property names in the equation are broken up and concatenated back together with the & sign. This is the trick that makes this work. You will need to change the text of those custom properties to match yours and break them into two parts. Where you do that is irrelevant. You just can't have the whole custom property name in one set of quotes.



                • Re: Extract the first five characters of custom property to BOM
                  Daen Hendrickson

                  If you are using SW2012 or later, the equation manager will not accept the equation. The trick is to first insert a valid equation such as 1+1 and exit the equation manager. You can then edit the equation and change it to the code snippet you want. The equation manager will complain and flag the equation and add unwanted quotation marks next time you view it, but it will accept it and it will run on rebuilds.


                  Thanks again to Josh Brady for figuring that out as well.