Jump to content

Iterate over stages


---
 Share

Recommended Posts

Dear all, 

I'm a beginner in python and I've got a question. 

We want to implement the attached method to all our stages (about 50) (in this example there are just 5). To the best of my knowledge, it is necessary to apply a for-loop and iterate over a list. I think the variable 'stage' in line 13 is a list object, but there is an error message when I insert more elements. Moreover, we are interested in an alternative to manually add the elements. Generally I would apply the method '.append' but this also rises an error message. 

We would be very thankful for your held concerning any hints or solutions! 

With kind regards, 

Christina        

stage iteration request.png

Link to comment
Share on other sites

Hello Christina,

this worked for me in a sample project. The range is the number of stages in the project:

# -*- coding: utf-8 -*-

import gom

for i in range(len(gom.app.project.stages)):
	gom.script.sys.show_stage (stage=gom.app.project.stages[i])
	gom.script.sys.restore_point_selection (elements=[gom.app.project.actual_elements['Cylinder 1']]) #insert surface comparison here
	gom.script.selection3d.invert_selection ()
	gom.script.cad.delete_selected_3d_area (reset_deviation_values=True)

Regards,

Nanno

Link to comment
Share on other sites

Dear Mr. Muehl,

thank you for the helpful hint. The cut within the surface comparison works. 

Furthermore, we would like to align and cut all stages by a defined plane in one step. We recorded the code and added the for-loop at the beginning to address all stages. Unfortunately, applying the actual script, only the CAD-model is cut and an error message raised. I attached a screenshot. 

Would it be possible to check our code in order to improve the cut of the stages, please.

Thank you very much for your help! 

Christina  

 

iterate_over_stages_cut_with_plane .png

Link to comment
Share on other sites

Hello,

the prealignment and other alignments for every stage are calculated for every stage individually anyways - there is no need to script this. (Assuming "separate stage transformations" is chosen in the dialog for the prealignment).

Maybe the script will work without this? Was the selection in 3D recorded correctly on the mesh?

Regards,

Nanno

 

Link to comment
Share on other sites

Dear Mr. Muehl,

we are interested in a visualization tool for stl-files. Applying a python code, we can parse stl files and receive for each triangle the following coordinates-for example:

---- TRIANGLE ----

normal:(-0.7114545702934265, ', ', 0.012907953932881355, ', ', -0.7026135325431824)

x(22.701526641845703, ', ', 39.65592575073242, ', ', -1.7217224836349487)

y(22.728918075561523, ', ', 39.774959564208984, ', ', -1.7472717761993408)

z(22.75603675842285, ', ', 39.54340744018555, ', ', -1.778985619544983)

Might it be possible to insert those coordinates and select the triangle described by those coordinates? 

I started some first tries, but they were not successful. 

1. I selected one triangle on the surface and recorded the scripting. The result was: one point and three coordinates are given, is this maybe the normal vector, because I selected the surface of the triangle? I rather expected coordinates like in my example above. (please see triangle_select)

2. Then, I displayed the points of the stl-file and selected one point.  I have selected only one point and I received some coordinates, but there are more than 40 packages of x,y,z- coordinates. I can not reconstruct, why I receive this amount of coordinates. To the best of my knowldge, one point should have three coordinates. (please see point_cloud_with_surface)

We would like to use the possibility of parsing a stl- and addressing one triangle by those coordinates. Would it be possible for you to support us and give us an approach for this project? 

 

I look forward to your answer !

Kind regards 

Christina

point_cloud_with_surface_results_.png

triangle_select.png

Edited
forgot the pictures
Link to comment
Share on other sites

 Share

×
×
  • Create New...