2009 SP5: Reset S/N Counter...

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?

Thanks,

Richie

SolidworksSolidworks Pdm enterprise Pdm
Answers 7
SF
SF 2010-05-27 Best Answer

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

http://www.pdmsolution.com

comment imagecomment image
SF
SF 2010-05-28

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.

SF
SF 2010-05-28

OK, sorry about that.

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

Devon Sowell

http://www.pdmsolution.com

SF
SF 2010-05-28

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.

JS
JS 2010-05-28

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

SF
SF 2010-05-28

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

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


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

comment imagecomment image
CL
CL 2012-08-16

Have you gotten any further than this I would like it to reset with a button or a variable of some sort.