select only faces (elements) on the front Zplane view thought python

Hello,

I have the result of a clip (crinkle on), that looks like the following:

this is the view in the Z+ (set view direction to Z+) I would like to select only the faces i can ‘see’ from this view, but programatically.
the best or more nearest workflow i could find for this was:

extract surface so i only keep the quad elements.

generate normal surfaces (with consistency and flip normals ON)

use a threshold over the normal surfaces of Z direction with a lower bound of 0 and upper of 10000
this selects almost all the desired faces, but it selects some other faces and also some do not:

outside of using something like connectivity filter (which for some reason does not work as I expected…image after) and extract the region with highest surface area.

how could I improve this workflow? i would like at least to remove the floating faces….

okey, the connectivity i succesfully applied, by using a clean to grid filter before, it looks like one of the filter was duplicating points.

Nevertheless, the issue of having some holes, as some of the normals are Z neg but really small, exists, if anyone has a better solution to ‘get this faces’ would be appreciated.

Hi @otaolafr

Have you tired to use the selection feature to select the visible faces?

Using trace recording, you can look at the corresponding python API call: set a selection area with SelectSurfaceCells(Rectangle=[277, 43, 1112, 843], Modifier=None) then create an ExtractSelection with the active source as the surface.

1 Like

hey francois,

nice to cross you in the discourse, i actually finished using this, and actually found an issue with this (i mentionned you in the openfoam discord) and i created an issue in this regards that mathieu confirmed that is present. basically, selectSurfaceCells, is missing cells depending on the zoom of the viewer, therefore if one use it from the hole geometry view (view.resetCamera(True,0.99)) it will fail to select several of the cells (that when one zooms without changing the camera, it will select them). for this reason i did not post this as solution to this post and wainting to solve this issue in paraview/ or find another solution to solve this.