Jump to content

How to access results of surface point inspections within the script faster?


Recommended Posts

Hello GOM-Team,

after creating evenly distributed surface points on a surface component I run several inspections on these points. The GUI shows the result table of these inspections. In order to proceed calculations based on these inspections I need to have access on the results values within my script.

My current workaround is to access the results value by looping through every point, inspection type and stage:   x_strain = gom.app.project.inspection['Point ' + str(i+1) + '.epsX'].get ('result_dimension.measured_value')  

This procedure works, but this is also very time consuming (<30min). Another workaround would be to programmatically save the result table as CSV, reopen the CSV within the script and write the content to a Python list. But this method is not practicable for my final application, too.

Is there a more elegant and faster way to directly access the values from the inspection result table programmatically?

Thank you very much.

Regards,

Steffen

Link to post
Share on other sites

Hi Steffen,

which version of GOM Software are you using?
Do you have NumPy installed? In this case you can refer to the attached script to see how you can get inspection result values for all stages in a numpy-array quite fast.

The trick is to use the "in_stage"-accessor (which will work without NumPy, too!)

x_strain = gom.app.project.inspection['Point ' + str(i+1) + '.epsX'].in_stage[gom.app.project.stages[j].index].result_dimension

Regards,
Theo

get_inspection_values_as_numpy_array.py

Edited by Theodor Moeller
No need of NumPy for "in_stage"-accessor.
Link to post
Share on other sites

Hi Theo,

 

thank you very much for your fast reply. Yes, I have NumPy installed. Will check your suggestions tomorrow and let you know if everything woks as intended.

Regards,

Steffen.

 


 

.

 

Link to post
Share on other sites

by the way: We are using GOM Correlate Professional 2020

 

Edited by Steffen Mayer
Link to post
Share on other sites
  • 2 weeks later...

Hi Theo,

after testing your suggestions with numpy my code is still very slow. So I tried a simple CSV-export. This is much faster, but a inconvenient solution.  But I'm wondering why some code is still very slow. In order to adopt the csv export to a variable number of inspections I tried this:

inspectionList = []
for k in range(gom.app.project.project_statistics.all.total_number):    
    inspectionList.append(gom.app.project.inspections_not_in_reports[k])   #inspection names reading takes way too long! No success with numpy and predefined array size

gom.script.table.export_table_contents (
    cell_separator=';', 
    codec='utf-8', 
    decimal_separator=',', 
    elements=gom.ElementSelection (inspectionList),
    file=export_path, 
    header_export=True, 
    line_feed='\r\n', 
    sort_column=4, 
    sort_order='ascending', 
    template_name='Values', 
    text_quoting='', 
    write_one_line_per_element=False)

The first loop, that reads the inspections takes about 2 minutes! (1400 inspections). I tried to run this code also in the none editing mode an dispaled the "inspectionList.append"-Method. No difference. Is there any hidden setting, that slows down my code execution? 

 

Thank you very much.

Link to post
Share on other sites

I am not quite sure, what the for-loop is intended to do.

gom.app.project.inspections_not_in_reports

already contains all inspection elements, which are not in reports. To loop through them by an index from another token

gom.app.project.project_statistics.all.total_number

seems not to make sense for me.

Which kind of elements you want to export? Maybe there is a better collection mechanism.

BTW: Python can be faster with list comprehensions than with loops using append. This would be something in this style:

elements = [element for element in gom.app.project.inspections_not_in_reports if element.type == 'inspection_dimension_scalar']

But you already mentioned, that this is not the issue for you.

I would suggest, that "gom.app.project.inspections_not_in_reports" is build up each time when it is called. This means you have to loop for all inspections through all reports and this is done in a loop for all elements counted in the project statistics. For 1400 inspection elements this may take some time. Maybe a list comprehension with a useful filter is a solution for this issue, too.

Link to post
Share on other sites

Hi Theo,

after intensive discussions we came to the conclusion, that simple CSV-File export of the results is the best sulution. The data within the the CSV is then processed within a separate application.

Thank you very much for your support.

 

Regards,

 

Steffen

Link to post
Share on other sites
×
×
  • Create New...