Help: Rhino.Geometry.Mesh.CreatePatch() questions

I look forward to the update since when I use the duplicate-curve-hack then that generates an edge that will extrude. So thanks for fixing that.

And another thing, could you consider adding a general direction analysis to your meshPatch output? It seems that the result is downward facing most of the time. Which doesn’t make sence sine meshPatch is mainly a 2.5D operation (Allways oriented to the XY plane):slight_smile:

MeshPatch accepts CURVES for internal use, just not boundry. It has an angleTolerance setting :slight_smile:

image

Can you upload the curves of the latest example?

Here is your previous example cleanly meshed with quads. The pink lines are the base polylines.

Hey, thanks for your interest and help mr Pirate :slight_smile:
But I know what I am after here, I even wrote my own SubD tool two years ago since I wasn’t happy with how normal SubD altered the base geometry, so my interest is purely to use the curves as they come and build a mesh according to those :slight_smile:

(I set them up based on slope analysis and height constraints, so therefore I need the mesh to do as I say, and I need nurbs curves for efficient blends and since altering polylines can sometimes be a drag (pun intended). )

1 Like

Here is a typical example of what I need to work with:


Those heights are important and therefore the boundry must be driven by curve segments so i can quickly adjust the boundry, and then I just sample those curves and convert them to polylines by a given factor. Tris or Quads are not important as I just need a quick mesh surface with a thickness for heigh analysis and overall visual evaluation.

RH-53052 is fixed in the latest Service Release Candidate

1 Like

That is fantastic, thanks for the superfast handling, I am downloading the sr candidate now and will give it a test!

Hi @dan, it works, but something else is broken now. There seems to be a memory leak in meshpatch that crashes rhino when I run an older script I have, that never failed before.
It throws an error about skipping boundry and then hangs until Rhino crashes.

I don’t know what causes it, and don’t have time to bugtrack now though. So this is just a heads up.

Not so much smarter here, but it crashes Rhino today as well.
image

This is with only internal points.

Hi @tim

I had time to look at this today and it seems that it fails when only points are used as input. (That used to work before)

Can you take a look at this code and see if you can update the patch command? Or explain why this doesn’t work any more?
Thanks!

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

tol=sc.doc.ModelAngleToleranceRadians
InnerPts = rs.GetPoints()
if InnerPts:
    patch=Rhino.Geometry.Mesh.CreatePatch(None,tol,None,None,None,InnerPts,True,32)

You have to cast the first None or the compiler cannot determine which of the overloaded functions you want to call. It would look something like this in C#. Not sure how that gets scripted.

        test = Mesh.CreatePatch((PolylineCurve)null, 15 * Math.PI / 180.0, null, null, null, innerPoints, true, div);

Since you’re passing null anyway you can use either type, Curve or Polyline.

Do you have an example file, or set of steps, to exhibit the crash/memory leak you mentioned earlier?

The crash happens in a script that was compiled, but that plugin works very fine in the previous builds.
And the above patch=Rhino.Geometry.Mesh.CreatePatch(None,tol,None,None,None,InnerPts,True,32) is from that compiled script.
(I just removed all the other stuff that was going on to clean up curves and extract points etc, but that is not where the system hangs.)

AND the point is that the above script doesn’t work, but it used to.

There are 2 functions now with the same name and all of the same parameters but the first. The first parameter can be a Curve or a Polyline. If you call the function with None for the first parameter the compiler can’t tell which function you want, so it pukes. Seems brutal that it crashes but I don’t know how that stuff works, maybe that’s normal. I’ll ask Dale when he gets in if there’s a better way to do the overload. In C# it won’t even compile it you don’t cast the null so it’s not an issue there. Bear in mind, this is only a problem when null is used for the first parameter. If you pass a Curve or Polyline it will work as it has.

That all makes sense, but I just worry that if you change this for V6 somebodys elses scripts will also suddenly fail, so IF a naked None is cast for the first parameter could it not just add a Curve=None?

I talked to Dale about this and, while we could change the parameter order for the function that takes a curve, we feel that the way it’s overloaded now is best. We have a document that is meant to address this for Python coders. By that, I mean how to fix their code to work with the SDK enhancement. See https://developer.rhino3d.com/guides/rhinopython/python-overloads/

1 Like

Man… that stuff is difficult to understand for a simple python user… :frowning:
IMO the python version should be so simple to use that it accept a “None” as an input when neither a curve nor a polyline will be used. Having to define a nullcurve doesn’t make sense and neither do I understand how to do that. So please reconsider for the sake of humanity :wink:

Edit: And of course what I really need is just the knowledge to define a polyline as “nothing” so the command will run. So if you could help me with that then I would be happy.
Because this doesn’t work:
OuterPolyLine = Rhino.Geometry.Polyline(None)

Maybe try with an empty Polyline (i.e. without the None):

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Polyline__ctor.htm

Thanks for trying to help out Anders.

That throws a “The outerBoundary must be closed”, it was the first i tried. And then I added the “None” but then it just says it can not be “None”.

I’m not really sure which specific overload you’re calling, but they can certainly be a bit tricky/convoluted when called from IronPython. But perhaps it’s as simple as passing it as empty Polyline enumerable, like a generic .NET list:


import Rhino
from System.Collections.Generic import List

emptyPolylineList = List[Rhino.Geometry.Polyline]()

It is for the first “None” in CreatePatch, the boundry curve. (I don’t want to use one on this particular script)

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

tol=sc.doc.ModelAngleToleranceRadians
InnerPts = rs.GetPoints()
if InnerPts:
    patch=Rhino.Geometry.Mesh.CreatePatch(None,tol,None,None,None,InnerPts,True,32)