# vmtkmeshmergetimesteps UnboundLocalError

**URL:** <https://discourse.slicer.org/t/vmtkmeshmergetimesteps-unboundlocalerror/30113>\
**Category:** VMTK\
**Created:** [June 19, 2023, 3:02am UTC](https://discourse.slicer.org/t/vmtkmeshmergetimesteps-unboundlocalerror/30113 "2023-06-19T03:02:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krentos\_Iliakopoulos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/krentos_iliakopoulos/32/66467_2.png) [@Krentos\_Iliakopoulos](https://discourse.slicer.org/u/Krentos_Iliakopoulos)\
**Post date:** [June 19, 2023, 3:02am UTC](https://discourse.slicer.org/t/vmtkmeshmergetimesteps-unboundlocalerror/30113/1 "2023-06-19T03:02:43Z")

</div>

Hi,

I try to trace particles using the tutorial [Particle Tracing | vmtk - the Vascular Modelling Toolkit](http://www.vmtk.org/tutorials/ParticleTracing.html) . Following the steps one by one, when i tried to execute vmtkmeshmergetimesteps like:

vmtkmeshmergetimesteps -directory ~C:/Users/Desktop/thesis/thesis1/kalokalo/Simulations/kalokalo/5/kalokalo-converted-results  
-firststep 0 -laststep 2800 -intervalstep 10 -velocityvector 1 -vector velocity  
-pattern all\_results\_%5s.vtu -ofile total\_results.vtu

i get the error message :

Traceback (most recent call last):  
File “C:\Users\DELL\anaconda3\envs\foo\lib\site-packages\vmtk\pypeserver.py”, line 46, in RunPypeProcess  
pipe.Execute()  
File “C:\Users\DELL\anaconda3\envs\foo\lib\site-packages\vmtk\pype.py”, line 324, in Execute  
scriptObject.Execute()  
File “C:\Users\DELL\anaconda3\envs\foo\lib\site-packages\vmtk\vmtkmeshmergetimesteps.py”, line 116, in Execute  
if (self.Pattern%step).replace(’ ',‘0’) in fileList:  
UnboundLocalError: local variable ‘fileList’ referenced before assignment

The pattern of the files is all\_results\_01234.vtu.  
Any help regarding the UnboundLocalError would be much appreciated!

Kind Regards,  
Krentos

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 20, 2023, 7:00pm UTC](https://discourse.slicer.org/t/vmtkmeshmergetimesteps-unboundlocalerror/30113/2 "2023-06-20T19:00:33Z")

</div>

It [looks like `InputDirectoryName` was not set correctly](https://github.com/vmtk/vmtk/blob/e9ebb8c420d7e2aba7a7e68c11355794e63f3716/vmtkScripts/vmtkmeshmergetimesteps.py#LL90C47-L90C65), for example you have set invalid path or there were no files in the directory.

It would be nice if you update the script to show a more detailed error message (e.g., input folder does not exist; no files were found in folder…) and send a pull request.
