Things don't always go as planned

I have been working on a new Python/C++ script to quickly import an .obj file of a mesh. But I was off by 1 in the indexing of the vertex indices and end up with this:

instead of this:

1 matters.



Moved to Scripting category.

Haha, cool stuff! Would you be so kind and explain, how you get Python and C++ to work together?

Yes I can help you with this. I will need to review my notes in order to supply you with the full details. But the basic idea is to hijack the Microsoft Visual Studio Rhino plugin flow to output C++ rather than C#. It is just a matter of setting up the headers inside Visual Studio and the details for doing this I got from Rhino support about a year ago. They were in a Forum posting which you might search and find now or after lunch I will look for it.

I am so happy to be able to boost the performance of my Python scripts with a C++ DLL (this is created by Visual Studio). I typically get speedup of 10X or more. It used to be more but I have gotten much better at writing fast Python code.

For the .obj file import Python/C++ is 10X faster than my Python only code and 20X faster than Rhino’s import tool (which probably handles more cases). So instead of waiting 3 min for my meshes with 25M faces to be imported, it takes only 9 sec.

I am still working on making it more robust by incorporating the features of Rhino’s Mesh.IsValid code, Mesh.Compact code and including CullDegenerateFaces.

Once it is done I will post it to the Forum with all the Python code, C++ code and a link to the DLL (which cannot be posted directly on the Forum).



Sounds great! I recon you then get some sort of compiled framework or library (i.e. dll, dylib). After that how do you “communicate” back and fourth with IronPython?
I guess you can “only” process very basic types (e.g. float, double, int, bool, etc.), not custom types/objects? And that is not to say that a lot can’t be achieved this way.

Sounds great!

Impressive, I remember your work from one of my previous threads about optimising my Python OBJ export from Grasshopper. :slight_smile:

Wow, that would be great!