Get Triangle count as command

Typically: "How do I... ", "How can I... " questions
Post Reply
das
Posts: 2
Joined: 19 Jun 2024, 11:51

Get Triangle count as command

Post by das »

Hello,

I need the triangle count of a shape created by the mesh import function.
I want to do subsequent calculations with it. I have to expand exisiting lua scripts. Therefore, I need it as a lua command.
Manually it is easy to find: Scene Object Properties >> Geometry >> Mesh Info >> Triangle Count. But like I said, I need it as a command.

Thank you for your help.

fferri
Posts: 1297
Joined: 09 Sep 2013, 19:28

Re: Get Triangle count as command

Post by fferri »

You can use sim.getShapeMesh and get the length of the returned indices array (which is 3 times the number of triangles).

In short: local numTriangles = #({sim.getShapeMesh(shapeHandle)})[2]//3

das
Posts: 2
Joined: 19 Jun 2024, 11:51

Re: Get Triangle count as command

Post by das »

Thanks for the fast reaction.

Post Reply