Jump to content

Reducing script


---
 Share

Recommended Posts

Hello,

I have a few questions. I'm a beginner in python so please help me solve the problem. I need to make a script that will open the saved measurement sessions from the location indicated by the user and then reduce them and save them in the same location. I made a script with a selection window (dialog) and the ability to select several files (measurement sessions) that I want to reduce, unfortunately after selecting files the script does not open them, reduces the session only the one in which it is currently running and closes it. Example: the KW26 folder has 120 files and I want the script to open the file (measurement session) to reduce it, save and close it, the process should be repeated until the end until it reduces all the indicated files from the selection window (dialog). My script in the attachment.

 

Regards

Radek

 I work ATOS 2018/2020.

zmniejszanie pliku.jpg

zmniejszanie pliku.py

Link to comment
Share on other sites

Hallo Radek,

What you need is a loop (after the dialogue window) over all files (measurements) that the user of your script has defined. In the loop, a file is opened, cleaned, saved under a new file name and then closed.

Link to comment
Share on other sites

Regarding the problem with the file name or with overwriting the original project...

# -*- coding: utf-8 -*-
import gom


# Define dialogue window with the query for project files to be edited
DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' ...
...
...

# Show dialogue window
RESULT=gom.script.sys.show_user_defined_dialog(dialog=DIALOG)

# Project files specified by the user
all_project_files = RESULT.input_field_for_project_files

# Loop over all project files
for actual_file in all_project_files:
	
	# Open current project file
	gom.script.sys.load_project (file=actual_file)
	
	# Name and path of the current project file
	actual_name = gom.app.project.project_file

	# Create new name for project file from old name
	new_name = actual_name[0:actual_name.find('.')]+'_reduced'+actual_name[actual_name.find('.'):]
	
	# Other actions in the loop
	...
	
	# Save the reduced project file under the new file name in the same directory
	gom.script.sys.save_project_as (file_name=new_name)

	# Close current project
	gom.script.sys.close_project ()

 

Link to comment
Share on other sites

  • 2 weeks later...

hello,
I solved the script problem with the help of interaktiv function to the specified folder by user , everything works, thanks for your help with renaming, regards.

R.

Link to comment
Share on other sites

 Share

×
×
  • Create New...