Closed polyline extrude to point - invalid mesh (python)

I try to create an ‘extrude polyline to point’ equivalent in python to output meshes. The vanilla node gives breps and gets too slow with too many input.

It sort of works, but the mesh is invalid. Any pointers would be appreciated? I gues it has to do with

        for i in range(len(base)):
            next_i = (i + 1) % len(base)
            face = rg.MeshFace(i, next_i, apex_index)
            mesh.Faces.AddFace(face)

[mesh_extrude_to_point.gh|attachment]
mesh_extrude_to_point.gh (22.6 KB)

Hi @crz_06,

Is this any better?

mesh_extrude_to_point.gh (20.4 KB)

– Dale

it’s a start … i do want to skip the srf/brep step and then back to mesh, as I assume it will get slow

Hi @crz_06,

Here’s a multi-threaded version in C#:

I adapted some Multi-Threading code from @Brian_Washburn and replaced Boolean methods with the Extrude To Point method.

Graph Space:

Model Space:

Maybe that will help you? (Sorry it’s not Python though)

20240709_Extrude_To_Point_Multi-Threaded_Response_01a.gh (25.4 KB)

3 Likes

I didn’t check the file (on Rhino 7 here), but something like this doesn’t even trigger the profiler on my system:


240710_MakePyramidMesh_AHD_00.gh (19.5 KB)

2 Likes

thank you all.
Interesting how the computation speeds are so different.
Also between old and new python nodes

attached all suggested solutions
[mesh_extrude_to_point_compare.gh|attachment]
mesh_extrude_to_point_compare_01.gh (695.1 KB)

From my testing, CPython 3 that implements RhinoCommon will be slower than IronPython, and IronPython is in turn slower than GHPython:

In some tests drastically, so if you’re going for Python + RhinoCommon + speed I’d recommend sticking with GHPython for now. And as always, following a few simple tricks can affect performance by a lot:

Also, in this case a performance bottleneck is calling Mesh.Append many times within the loop. If we do that just once, or alternatively wrap the pyramid meshes in the Grasshopper mesh type, the compute time drops quite severely:


270710_MakePyramidMeshes_AHD_01.gh (730.9 KB)

Note how the viewport is a lot more responsive if we only output one mesh for all the pyramids.

2 Likes

Thanks for your insightful feedback. I did notice some of the aspects you’ve mention, and figured it was just me as it didn’t make sense to me why not have a type hint would be faster (same for list/no list) :wink:

Thanks for the improve python code!

1 Like

Shaved a bit more off with threading, but generally speaking you’d gain more through simpler means by dropping down to C# once you start getting into 10000+ loops:


270710_MakePyramidMeshes_AHD_02.gh (745.9 KB)

1 Like