How can I get mesh data from a selected object in the station into an Addin?

I'm trying to create a robotstudio addin that operates on mesh data, but I can't find a good way to get the mesh data from a selection into an addin. All I need is a list of the vertices and indices, or just a list of Face or MeshFace objects. The closest I've gotten is the process below:

  1. Get the selected object from the Selection
  2. Cast the object as a Part
  3. Get the Mesh from the Part
  4. Get the MeshPart from the Mesh by indexing using the Fine detail level
  5. Get MeshFace data from theMeshPart

This makes logical sense, but the code isn't behaving how I would expect: The code keeps giving me single digit numbers for the amount of faces, even if the selected part has over a thousand faces. I've tried using the Mesh.closest() method instead of indexing, but it gives the same result. RobotStudio clearly knows how many faces the mesh actually has, since it's rendering everything properly, I'm just not sure how to get that data into my addin.

If anyone has a good way to get selected mesh data into an addin, I'd love to hear it!


Answers

  • michaelgreer
    michaelgreer Colorado
    Solved, you have to dig down to the MeshFace level and the data is contained in the vertices and triangleindices structures.