PDA

View Full Version : Question : loop problem... before to get crazy



cgvinny
01-22-10, 03:53 PM
Hey guys !

Wow I am really active in this forum which is not necessary a good new :D

OK So here is my problem.

I am trying to save image generated by Zbrush
I want the image names to be incremental (img001, img002, etc...)
and I want the script to check if the name doesn't already exists.

I have managed to do this but not for the last part (Zbrush overwrite my previous images when i relaunch zbrush for example)

I know I have done something wrong but what ?? :o

here is the code:

[VarDef, VGLoopcounter, 1]
[VarDef, VGPSDName, "VG\Sheets\sheet_0000.psd" ]


[Loop, VGLoopcounter,
[VarSet, VGPSDName, [FileNameAdvance, VGPSDName ] ]


[If, [FileExists, VGPSDName ] ,
[Varset, VGLoopcounter, VGLoopcounter+1 ]
]
]

[FileNameSetNext, VGPSDName ]
[Ipress, Document:Export ]


Pls save my soul ! ;-)

Thx !

TVeyes
01-22-10, 07:00 PM
Hi

You cannot add +1 to the VGLoopCounter in the middle of a loop. It must be set once at the start of the loop.

You could use a near infinte loop instead and a conditional test after the loop.

[VarDef, VGLoopcounter, 99999]
[VarDef, VGPSDName, "VG\Sheets\sheet_0000.psd" ]
[VarSet, AvailableFilename, 0]

[Loop, VGLoopcounter,

[If, [FileExists, VGPSDName ] ,
//do nothing. advance filename at end of loop
,
[VarSet, AvailableFilename, 1]
[LoopExit]
] // end of If statement

[VarSet, VGPSDName, [FileNameAdvance, VGPSDName ] ]

] // end of loop

[If, AvailableFilename,

[FileNameSetNext, VGPSDName ]
[Ipress, Document:Export ]

,

[Note, "You have used 99999 files. Don't you think it is time to delete something ? !"]

]


Please don't worry about asking too many questions. That is how we all learn a new language.

Keep up the good work.

cgvinny
01-25-10, 09:41 AM
Thx it works now !

I keep some reflex of some other script language which makes me do some mistakes ;)

but sor far i am happy with the possibilties Zscript offers.

I'll continue to work hard