Jump to content

Measurement Information Table (automate)


---
 Share

Recommended Posts

Hello,

My goal:

To export a table containing the measurement information (objective, temperare, point in 3D etc..). This data is also found in right menu after clicking a scan (see picture). Though no export function is available.

 

My effort:

So far I have found no way to export data directly. I started creating a script (see code below). I managed to loop the scans and get some of the data.

 

My question:

How can I find a list with all member names? For now I am lucky and find some names.

I attempted to search object with: dir(j) or vars(j) but got stuck from there.

I thought the easiest is creating numpy table and exporting to CSV (but I think I can do that, did that before).

Please forgive me if there are easier ways unknown to me.🙃

image.png.b08adf76cdf00f2fabd3ebfcc9fb6cd2.png

 

Sample Code (partial data is found):

import gom

all_actual_meshes = [i for i in gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'measurements']})]

for i in all_actual_meshes:

	for j in i.measurements:
		
		print(j.name)
		print(j.type)
		#print(j.excluded_from_computation)???		
		print(j.measurement_resolution)
		print(j.transformation_method)
		#print(j.preview_points_in_3D_view)???
		#print(j.computation)???
		print(j.sensor_type)
		print(j.measuring_volume_name)
		print(j.measuring_volume_length)
		print(j.measuring_volume_width)
		print(j.measuring_volume_depth)		
		print(j.calibration_deviation)
		print(j.calibration_deviation_optimized)
		print(j.calibration_camera_angle)	
		print(j.comment)
			
		print("")

 

Output:

M1
scan
full_resolution
reference_points
ATOS 5 (12M)
MV320 (320x240x240)
335.0
260.0
235.0
0.029686492240571464
0.009335919661607923
0.4841352701874103


M2
scan
full_resolution
reference_points
ATOS 5 (12M)
MV320 (320x240x240)
335.0
260.0
235.0
0.029686492240571464
0.009335919661607923
0.4841352701874103 

 

Link to comment
Share on other sites

Found the solution:

 

1) Right Click in editor:

2) Select element.

3) Select keyword from list!

 

image.png.f52532f7ab5dbc5e799c1b8604635d0d.png

 

 

image.png.cb0151a1f561d4b3b8e61ae743622c7f.png

Link to comment
Share on other sites

My goal is fulfilled. Below my findings and learning. Some recommendations experiences users is welcome. 

Learnings:

  1. With right mouse button: insert=>element value F2=> the specific element names can be found and inserted.
  2. I had problems that numpy and pandas where not available. 
    • Installed the package: Python Base (2020) from Zeiss here: https://connect.gom.com/display/GPF/Python+Base  
    • Package contains: numpy, pandas, scipy etc...
    • Make a full disk image from GOM atos system (if something goes wrong). 
    • Install package by clicking + (plus) button in list below.
    • image.png.f95f481a0fe4e829c74134a32a74b843.png

Learned about packages:

It was unclear how to install. First attempted with: scripting=>script choice=>tools=>install python package. But was not able to install the downloaded package. Likely this option is only for Python packages. The Python Base (2020) installed without problems with Gom packages as described above.

My code that creates table measurement settings:

Needs some tidying up but functional. I am very happy with the possibilities, for a new fresh GOM Atos user (two months). But with data analysis experience Python.

import gom
import numpy as np
import pandas as pd 
from pathlib import Path

#file and stage name
file=gom.app.project.name
path=gom.app.project.project_file
stage=gom.app.project.stage

#Messagebox to select path			
RESULT=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \
' <title>Save Measurement Setting</title>' \
' <style></style>' \
' <control id="OkCancel"/>' \
' <position></position>' \
' <embedding></embedding>' \
' <sizemode></sizemode>' \
' <size width="271" height="172"/>' \
' <content columns="1" rows="3">' \
'  <widget column="0" type="label" row="0" rowspan="1" columnspan="1">' \
'   <name>label</name>' \
'   <tooltip></tooltip>' \
'   <text>Export measurement data to:</text>' \
'   <word_wrap>true</word_wrap>' \
'  </widget>' \
'  <widget column="0" type="input::file" row="1" rowspan="1" columnspan="1">' \
'   <name>folder</name>' \
'   <tooltip></tooltip>' \
'   <type>directory</type>' \
'   <title>Choose Folder to export to</title>' \
'   <default>' + path   +   '</default>' \
'   <limited>false</limited>' \
'   <file_types/>' \
'   <file_types_default></file_types_default>' \
'  </widget>' \
'  <widget column="0" type="input::string" row="2" rowspan="1" columnspan="1">' \
'   <name>filename</name>' \
'   <tooltip></tooltip>' \
'   <value>' + file + '</value>' \
'   <read_only>false</read_only>' \
'   <password>false</password>' \
'  </widget>' \
' </content>' \
'</dialog>')

folder_path = Path (RESULT.folder)
filenew=RESULT.filename
print(folder_path)

#Define output array
array=[]
		
#format output table		
columns=['file','stage','scan','path','item','text','value','unit']

#get list measurement series
all_scans = [i for i in gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'measurements']})]

#Loop all measurement scans
for i in all_scans:
	for j in i.measurements:

		#Scan Name
		scan=j.name
		
		value=j.gray_value_feature_movement_compensation
		unit="text"
		array.append([file,stage,scan,path,"gray_value_feature_movement_compensation","",value,unit])		
		
		value=j.gpu_acceleration_used
		unit="text"
		array.append([file,stage,scan,path,"gpu_acceleration_used","",value,unit])		
		
		for k, l in enumerate(j.points_per_exposure_time):
			value=l
			unit="points"
			array.append([file,stage,scan,path,"points_per_exposure_time_" + str(1+k),"",value,unit])

		value=j.calibration_snap_mode
		unit="text"
		array.append([file,stage,scan,path,"calibration_snap_mode","",value,unit])

print(folder_path)
print(file)
file_name=os.path.join(folder_path,filenew+".csv")
pd.DataFrame(array).to_csv(file_name, header=columns, index=False, sep='\t')

 

 

Edited
Link to comment
Share on other sites

Detected a bug. Here a fix to the code. Cannot edit previous post anymore: edit time is very short 🙄.

The default path in messagebox was including filename. This gave an error when not changing the path.

str(os.path.dirname(path)) 

 

Fixed:

import gom
import numpy as np
import pandas as pd 
from pathlib import Path

#file and stage name
file=gom.app.project.name
path=gom.app.project.project_file
stage=gom.app.project.stage

print(path)

#Messagebox to select path			
RESULT=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \
' <title>Save Measurement Setting</title>' \
' <style></style>' \
' <control id="OkCancel"/>' \
' <position></position>' \
' <embedding></embedding>' \
' <sizemode></sizemode>' \
' <size width="271" height="172"/>' \
' <content columns="1" rows="3">' \
'  <widget column="0" type="label" row="0" rowspan="1" columnspan="1">' \
'   <name>label</name>' \
'   <tooltip></tooltip>' \
'   <text>Export measurement data to:</text>' \
'   <word_wrap>true</word_wrap>' \
'  </widget>' \
'  <widget column="0" type="input::file" row="1" rowspan="1" columnspan="1">' \
'   <name>folder</name>' \
'   <tooltip></tooltip>' \
'   <type>directory</type>' \
'   <title>Choose Folder to export to</title>' \
'   <default>' + str(os.path.dirname(path))   +   '</default>' \
'   <limited>false</limited>' \
'   <file_types/>' \
'   <file_types_default></file_types_default>' \
'  </widget>' \
'  <widget column="0" type="input::string" row="2" rowspan="1" columnspan="1">' \
'   <name>filename</name>' \
'   <tooltip></tooltip>' \
'   <value>' + file + '</value>' \
'   <read_only>false</read_only>' \
'   <password>false</password>' \
'  </widget>' \
' </content>' \
'</dialog>')

folder_path = Path (RESULT.folder)
filenew=RESULT.filename
print(folder_path)

#Define output array
array=[]
		
#format output table		
columns=['file','stage','scan','path','item','text','value','unit']

#get list measurement series
all_scans = [i for i in gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'measurements']})]

#Loop all measurement scans
for i in all_scans:
	for j in i.measurements:

		#Scan Name
		scan=j.name
		
		value=j.gray_value_feature_movement_compensation
		unit="text"
		array.append([file,stage,scan,path,"gray_value_feature_movement_compensation","",value,unit])		
		
		value=j.gpu_acceleration_used
		unit="text"
		array.append([file,stage,scan,path,"gpu_acceleration_used","",value,unit])		
		
		for k, l in enumerate(j.points_per_exposure_time):
			value=l
			unit="points"
			array.append([file,stage,scan,path,"points_per_exposure_time_" + str(1+k),"",value,unit])

		value=j.calibration_snap_mode
		unit="text"
		array.append([file,stage,scan,path,"calibration_snap_mode","",value,unit])

print(folder_path)
print(file)
file_name=os.path.join(folder_path,filenew+".csv")
pd.DataFrame(array).to_csv(file_name, header=columns, index=False, sep='\t')

 

Edited
Link to comment
Share on other sites

Here is the code I am currently using. Hope I did not make typos.

Just wanted to share my learnings.

Not all measurement scan settings are included, but with this topic one should be able to add them.

Note that some elements require extra loop like: scan intensity exposure times. 

I made a simple catch (show messagebox) to check if scan files are present yes/no. 

No error catching when no file is opened. System catches this error with pop-up.

Note: Some knowhow on Python is required. 

Really enjoy the Gom and the possibilities.

Still allot to learn, the number of tools in GOM is uncountable. 

But just like craftsman first getting to know your tools! And just started learning!

 

[code now attached as file - wish by Vincent]

SaveMeasurementSetting.py

Link to comment
Share on other sites

 Share

×
×
  • Create New...