5 Replies Latest reply on Sep 30, 2014 10:34 AM by Michael Ferraro

    EPDM Dispatch Character Counts

    Michael Ferraro

      Hello All,

       

      We have very recently bought EPDM and I am working on developing our data cards.

       

      Our material library has many materials that have been added that all have the following format:

       

      [MATERIAL] [FINISH] [HEAT TREAT]

       

      What we would like to do is put these three values onto the data card in 3 separate fields.

       

      Material = Information in 1st set of Brackets

      Finish = Information in 2nd set of Brackets

      Heat Treat = Information in 3rd set of Brackets

       

      I had worked this out in dispatch and thought I had it functioning until I realized I made a mistake. If I set a parts material to be [UHMW WHITE] it ends up putting UHMW WHITE into Material and into Heat Treat.

       

      Is there a way in dispatch to count the number of occurrences of a character? I would then be able to set up a few If statements pending what the value is. If only one "[" set the Material property, if 2 "[" set the Material and Finish and if 3 "[" set the Material Finish and Heat Treat.

        • Re: EPDM Dispatch Character Counts
          Michael Dekoning

          I'm confused about what dispatch has to do with a data card.

          Are you concatenating the three values into another variable?

            • Re: EPDM Dispatch Character Counts
              Michael Ferraro

              Our Data Card looks like the following:

               

              Data Card - Custom.PNG

               

              I would like to use Dispatch to take the material picked in SolidWorks and break it into the 3 corresponding pieces on the Data Card.

               

              So when an engineer picks a material in our material database that has the form [MATERIAL] [FINISH] [HEAT TREAT] it will take that single string and break it into 3 pieces and display it on the data card shown above.

               

              Does that make sense?

            • Re: EPDM Dispatch Character Counts
              Earl Navarro

              I t

              You could accomplish this by using the functions in the link below.

               

              2011 SOLIDWORKS Enterprise PDM Help - Functions for Variables

              b

               

               

              example

              VARORIG="[MATERIAL] [FINISH] [HEAT TREAT]"        this is your original variable from solidworks

               

              first use the LENGTH function to count the total number of characters in the string

              VARLENGHT=length(VARORIG)

              return value =31

               

              second use the LEFT function to eliminate the upper right hand bracket

              VARLEFT=left (VARORIG,VARLENGTH-1)

              return value=[MATERIAL] [FINISH] [HEAT TREAT

               

              third use the RIGHT function to remove the left hand bracket

              VARRIGHT=RIGHT([MATERIAL] [FINISH] [HEAT TREAT)

              return value=MATERIAL] [FINISH] [HEAT TREAT

               

              fourth use the FIND function to find the first occurrence of the right hand bracket

              varFIND1=FIND(VARRIGHT,"]")

              return value=8

               

              now you can extract the MATERIAL portion by using LEFT function

              varMATERIAL=LEFT(VARRIGHT,varFIND1-1)

              return value=MATERIAL

               

              then use the REVERSEFIND function

              varFIND2=REVERSEFIND(VARRIGHT,"[")

              return value=19

               

              now you can extract the HEAT TREAT portion BY using RIGHT function

              varHEATTREAT=RIGHT(VARRIGHT,VARLENGHT-2-VARFIND2)

              return value =HEAT TREAT

               

              now to extract FINISHI portion BY USING MID function

                varFINISH=MID(VARRIGHT,varFIND1+3,(varFIND2-2)-(varFIND1+2))

              return value=FINISH

               

              hope this help

                • Re: EPDM Dispatch Character Counts
                  Michael Ferraro

                  Earl,

                   

                  I seem to be having an issue using this. It seems like the FIND function doesn't like FIND(abcd, "]"). It would find items without the quotations on either end however when I add the quotations it seems to return odd values.

                   

                  I also ran into another issue when I used the above which I think I may have a solution. If the user picks something that only has 2 of the fields above i.e. [MATERIAL] [FINISH] then it seems to mess up the reported results.

                   

                  I thought an easy solution to this would actually be to change the format slightly to something along the lines of [MATERIAL] {FINISH} (HEAT TREAT). However when I did this I cannot seem to get EPDM to find the closed parenthesis shown below:

                   

                  FIND(%d-Listed Material%, ))

                  and FIND(%d-Listed Material%, ")") doesn't seem to work either.

                   

                  Have you had this issue before?

                   

                  Thanks,

                   

                  Mike