Reset counter between each part

Hello

When I am on the SmartProperties of several welded bodies, I use a counter that allows me to number them from 001 to 0XX.

My problem is as soon as I change the Part file and I do the manipulation again, the counter does not start from 0, I am forced to reset the counter manually.

I want to know if the automation of this reset is possible according to a variable property between 2 files.

Here is my procedure in video:

SP.zip (7.3 MB)

Look in this thread if the answer helps you:

Edit: see also this more explicit topic it seems to me:

Hello;

To overcome this problem I created a small *.BAT file that overwrites the *.xml file of the counter (here SmartCounter_Num-mecanosoude.xml) by a copy whose increments start from ZERO.

I call this file (*.bat) via a button in my Smartproperties.

Contents of the BAT file:

@echo off

ECHO f | XCOPY W:\\Modeles_solidworks\Smart-Counter\SmartCounter_Num-mecanosoude.xml W:\\Modeles_solidworks\Smart-Counter\SmartCounter_Num-mecanosoude_OLD.xml /Y
ECHO f | XCOPY W:\\Modeles_solidworks\Smart-Counter\SmartCounter_Num-mecanosoude-RAZ.xml W:\\Modeles_solidworks\Smart-Counter\SmartCounter_Num-mecanosoude.xml /Y

cls
echo.
	
EXIT

And the content of the xml file so that the counter starts from Zero:

And in the Smartproperties:
image

(To be adapted according to your needs of course...)

Kind regards.

2 Likes

Thank you all for your answers.

I had read these forums but I can't get my way. This is because the counter resets to 0 when a property in the part file is changed. However, in my case, I want a reset as soon as the file is different.

Regarding the macro @Maclane, did you just do that? Or do you have other steps?
I don't understand how you do it exactly. Could you clarify or rephrase please?

Hello;

I copied a first xml from a counter with the " Zero " increment values. (StartValue=0)
=> that I called Smartcounter_Num-mechanical-welded-RAZ

I use a second *.xml " Classic " counter to add the increments on my properties:
=>Smartcounter_Num-mecanosoudé.xml

And the *.bat file for resetting to Zero is used to replace the file of the counter used (Smartcounter_Num-mecanosoudé.xml) by the one whose starting value of the increment is zero (Smartcounter_Num-mechanically welded-RAZ)


The Smartcounter_Num-mechanically-welded-OLD file is a backup copy of the Smartcounter_Num-mecanosoudé.xml file

Hoping to have been clearer...

Kind regards.

1 Like