I am a biology student using 3D models (.ply) of animal tracks.
For my project I need to extract the border of the mesh (_DupBorder) , extract the point (_ExtractPt) and export them as .txt.
It is really to do manually but i really need to automate this because I have than 3300 models and i am a complete beginer in coding.
All my data are in one same folder, I suppose I need some kind of loop opening mesh by mesh and extracting the points.
Here’s a simple approach using the GHPython component to get the naked edge loops vertices (using RhinoCommon API mesh functionality), and then exporting their coordinates using the Grasshopper Panel streaming functionality:
You can also write to file using the standard Python file writing functionality. If you for some reason don’t want to go through Grasshopper (which I would highly recommend), you could implement the mesh/polyline methods I’m calling above and the Python write function in a “normal” RhinoPython script.
You need to reference your mesh in Grasshopper. You can simply right-click the Mesh component, click on Set One Mesh, and select your mesh in Rhino. Et voilà, you’re done!
Your Mesh component should now output the mesh in question and forward it to the GHPython component, provided by Anders. You can for instance use a panel to see what a component outputs.
Generally speaking, this is how you reference Rhino geometry (e.g. points, lines, curves, surfaces, breps, meshes, etc.) in Grasshopper.
I’d also recommend the Grasshopper route, since it’s more straightforward and beginner friendly than scripting directly in RhinoPython. You are able to fragment your process into smaller tasks and debug each task, and don’t have to run the entire script each time. You can also preview what happens, what data is output at which step, and how it is structured, which if far more cumbersome in RhinoPython.
Here’s how I’d imagine your process:
Come up with a way to import your PLY files directly into Grasshopper.
Extract the border information
Export the text files
The first part is probably the hardest. Could you provide one PLY file for testing?