Jump to content

Counting function with STL Export


---
 Share

Recommended Posts

Hello all,

 

I'm trying to create a simple and full digitalization program with export of the final STL to a folder

Just to make an operator switch part on machine on a daily shift  

My program creates the forder and open the same to a easy visualization

               

                          os.mkdir (r'C:\...') #create the folder 

                          os.startfile(r'C:\...') #open the folder

 

Then I export the STL to this folder and the objective is to had Part 1, Part 2 ....

I use the export script with record 

            gom.script.sys.export_stl (
            bgr_coding=False, 
            binary=True, 
            color=False, 
            elements=[gom.app.project.parts['Part'].actual],  
            export_in_one_file=True, 
            export_stages_mode='current', 
            file='C:/Users/user/Desktop/Produção/teste/Part.stl', 
            length_unit='mm', 
            set_stl_color_bit=False,)

 

On this script I try to add a count function but with no success and after a few try I try to change the exportations stl names on the folder      

            for file_name in os.listdir(folder):
                       source = folder + file_name

                      destination = folder + 'Part_' + str(count) + '.stl'

                      os.rename (source, destination)

                      count =+1

But with this code he creates the Part 1 and Part 2 but on the 3 run he change the names of the parts to Part 3 and Part 4 and had one new export with the name Part 5 for a program while (count < 3)

Is it possible to had the rename process on the export script??

 

 

               

Link to comment
Share on other sites

 Share

×
×
  • Create New...