7 Replies Latest reply on Aug 16, 2012 1:13 PM by Craig Lalumiere

    2009 SP5: Reset S/N Counter...

    Richie Yosten

      Here Is the format I'm looking for:


      ...but I want to reset the two digit portion every day.  I'm not even seeing a way to do this via the api.


      Am I missing something?




        • Re: 2009 SP5: Reset S/N Counter...
          Devon Sowell

          If the Serial Number generator was used 5 times in one day, then the "Next counter value" would be 6.


          Reset using the API, can't help you there


          Devon Sowell




            • Re: 2009 SP5: Reset S/N Counter...
              Richie Yosten

              I'm aware that you can reset the counter in that dialog...I want to reset it on a schedule (every day).  I don't see anything exposing that in the api.

                • Re: 2009 SP5: Reset S/N Counter...
                  Devon Sowell

                  OK, sorry about that.


                  I recommend Jeff Cope or Mike Spens for custom code writing, just google their names.


                  Devon Sowell


                    • Re: 2009 SP5: Reset S/N Counter...
                      Richie Yosten

                      I can code myself...I just don't see anyway to interact with the s/n generators via api.  I was wondering if I missed something.

                        • Re: 2009 SP5: Reset S/N Counter...
                          Jeff Sweeney

                          Yeah, I don't see any either. You may have to go directly to the counter's db table and reset it with SQL.

                            • Re: 2009 SP5: Reset S/N Counter...
                              Richie Yosten

                              That's what I was thinking...I hate to step outside of the api unless I have to.


                              Another alt that I've found is in the API help file (example): 

                              Creating Serial Numbers Using Visual Basic


                              Public Sub GetAddInInfo(ByRef poInfo As EdmLib.EdmAddInInfo, ByVal poVault As EdmLib.IEdmVault5, ByVal poCmdMgr As EdmLib.IEdmCmdMgr5) Implements EdmLib.IEdmAddIn5.GetAddInInfo
                                'Return information about this add-in to PDMWE in the struct
                                poInfo.mbsAddInName = "My serial number generator"
                                poInfo.mbsCompany = "The name of my company"
                                poInfo.mbsDescription = "Implements serial numbers."
                                poInfo.mlAddInVersion = 1
                                poInfo.mlRequiredVersionMajor = 5
                                poInfo.mlRequiredVersionMinor = 2
                                'Tell SolidWorks Enterprise PDM that we can generate serial numbers.
                              End Sub
                              Public Sub OnCmd(ByRef poCmd As EdmLib.EdmCmd, ByRef ppoData As System.Array) Implements EdmLib.IEdmAddIn5.OnCmd
                                'Check the upper and lower bounds of the array. 
                                Dim index As Long index = LBound(ppoData) 
                                Dim last As Long last = UBound(ppoData) 
                                If index <= last Then 
                                  Dim cnt As Integer 
                                  cnt = last - index + 1 
                                  'Create a temporary array we have full access to 
                                  Dim tmpArr(cnt) As EdmCmdData 
                                  tmpArr = ppoData 
                                  'Generate serial numbers for all of the affected files. 
                                  Dim CounterVal As String 
                                  While index <= last 
                                    CounterVal = tmpArr(index).mlLongData1 
                                    Dim s As String 
                                    s = "My serno(" + CounterVal + ")" 
                                    tmpArr(index).mbsStrData1 = s 
                                    index = index + 1 
                                  End While 
                                  'Return the updated data 
                                  ppoData = tmpArr 
                                End If 
                              End Sub

                              Obviously, you can get that format within the normal generator but it shows you can color outside of the box if you desire.