Jump to content

Accessing mesh data arrays


Recommended Posts

Hello support team,

I am writing a custom filter for a special application and I would like to have it written using functions avalaible in numpy, as it we have to process big amounts of points.


My question : how can I select a list of triangles on the mesh? (Or even better : maybe delete them directly from the mesh?)


Actually I am aware of the fonction gom.script.selection3d.select_triangle (point=gom.Vec3d()).

I would need something like gom.script.selection3d.select_triangles (triangles=[np.array (gom.app.project.parts[0].actual.data.triangle[0:2500]])

or like gom.script.selection3d.select_triangles (points=[list of gom.Vec3d])


Do not hesitate if you need me to rephrase the question.




Link to comment
Share on other sites

  • 2 weeks later...

I would suggest something like:

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

import gom
import numpy as np

CURRENT_STAGE = gom.app.project.get ('stage.index')

def SelectTriangles (mesh_element, tris):
	pts = np.array (mesh_element.data.coordinate)[CURRENT_STAGE]
	tri_pts = np.mean (pts[tris], axis=-2)
	gom.script.selection3d.deselect_all ()
	gom.script.cad.show_element_exclusively (elements=[mesh_element])
	for tri_pt in tri_pts:
		gom.script.selection3d.select_triangle (point=gom.Vec3d (tri_pt[0], tri_pt[1], tri_pt[2]))

if __name__ == '__main__':
	mesh_element = gom.app.project.parts[0].actual
	tris = np.array (mesh_element.data.triangle)[CURRENT_STAGE]
	SelectTriangles (mesh_element, tris[:10])


Link to comment
Share on other sites

  • 2 weeks later...

Please sign in to view this quote.

Thanks Theodor,

I will test it and give you some feedback.


Have a nice day.


Link to comment
Share on other sites


  • Create New...