Rhino.Geometry.Extrusion using a vector?

I’ve been struggling trying to get some curves properly oriented before getting them extruded using “Rhino.Geometry.Extrusion.Create()” but there was not fast way to deal with them and I jump to search for an extrusion function that let me specify an extrusion vector.

I’ve found “Rhino.Surface.CreateExtrusion()” but it doesn’t produce a close extrusion but an open Brep and then I have to close it using “myExtrusion.CapPlanarHoles(tolerance)” and at the end I don’t get an Extrusion but a closed Brep what is not what I would like.

My question: Is there any way to get a closed extrusion out of a planar curve specifying an extrusion direction?

Thanks in advance.

Maybe it is possible to modify the extrusion direction after it is created by Rhino.Geometry.Extrusion.Create(), using SetPathAndUp.

The documentation seems to suggest you can edit the direction of the extrusion after it has been created. I can’t test this right now, but it sounds useful for your case.

http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Extrusion_Create.htm
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Extrusion_SetPathAndUp.htm

Can you provide an image (or model) of the shape you are trying to create?

If you want a capped extrusion, I’d suggest using the Extrusion constructor and then setting the boolean flag for capped when defining the perimeter curve.

Extrusion ex = new Extrusion();
ex.SetOuterProfile(outer, true);

Hope this helps,

Jon

Hi!

Thanks, @jonm, @dale and @menno for your fast reply.

I’ve already done this. But the problem is not about capping the extrusion but defining a consistent group of extrusions from a group of closed and planar curves.

The history about this curves is long but easy they are just fractions of planar circular crowns around a shared axis (not center) that are the basic layout for some mad architecture proposal.

The planar arcs generated to build that circular crowns segments are created parametrically and all of them have the same radious. Them I copy them into a new variable with “copy.Copy(object)” and modify the radius with the desired width for the circular crown. Just a snippet (it is in a class context):

c = self.crvBase
offCrv = copy.copy©
offCrv.Radius += self.width

Adding some lines to connect both arcs and joining averything together I obtain the desired crown:

l1 = rg.Line(c.StartPoint, offCrv.StartPoint)
l2 = rg.Line(c.EndPoint, offCrv.EndPoint)

planCrv = rg.Curve.JoinCurves((c.ToNurbsCurve(),l1.ToNurbsCurve(),l2.ToNurbsCurve(),offCrv.ToNurbsCurve()))[0]

The problem is that those curves are not equally oriented. and that is a pain in the ass to get the rg.Extrusion.Create() method working. Indeed, I try to orient them checking the Z axis of the plane extracted from everyone. Another snippet:

> plane = planCrv.TryGetPlane()[0]

> if plane.ZAxis[2] != 1:
>        planCrv.Reverse()

But something strange happens. It works partially; if I try to change the radius of the initial arcs, at certain value, some curves flipped and this small snippet doesn’t affect them…

The thing is that getting some sleep I found a solution that doesn’t include to use rg.Surface.CreateExtrusion + rg.Brep.CreateFromSurface + rg.Brep.CapPlanarHoles and consequently needing to deal with a Brep (I’m searching an extrusion). What I though? Just use the las snippet check and use it to multiply the extrusion height in rg.Extrusion.Create() by “-1”. Snippet:

plane = planCrv.TryGetPlane()[0]

 if plane.ZAxis[2] != 1:
    extrusionHeight *= -1
 vol = rg.Extrusion.Create(planCrv,extrusionHeight,True)

The collateral damage is clear, I’m leaving behind some poorly oriented curves that probably I will need to deal with sooner or later creating the FEM model or some basic 3d elements for the rendering model.

I hope to be clear enough in my explanation. My English is a little bit rusty and this is quite a long post.

Thanks in advance.

Hi Angel,

It is almost never a good idea to compare floating point values in the way you are due to floating point rounding errors.

To determine whether or not the plane’s z-axis is parallel to the world z-axis, you might consider comparing vectors using Rhino.Geometry.Vector3d.IsParallelTo which will let you know if two vectors are parallel, not parallel, or anti-parallel.

Another option is to compare the angle between the vectors using Rhino.Geometry.Vector3d.VectorAngle.

Does this help?

1 Like

Yep!! It worked nicely :slight_smile: As you said the problem was the floating point rounding error.

Thanks for the reply and help :slight_smile: