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

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)

After talking to Steve we’ve decided to remove the overload that takes a Curve. You’ll just have to cook up your own polyline when you actually have an outer boundary. Apparently there’s a method on Curve called ToPolyline (or something like that) that you can call.

OK, so on the next wip it will be reverted back to how it was? That is no problem for me as I already had the conversion cooked up :slight_smile:

MeshPatch is not the most widely used tool so it makes sense to focus on other tasks! (And I now know how it works so personally I am good too!)

Thanks a lot for spending time on this though, it’s hugely appreciated @tim!

1 Like

One last thing, can you have a look at why meshpatch constantly chooses to set direction to -Z?
This happens on both the script version and the built in function. It makes sense to me that this should be reverted.

And thanks for adding the open internal curve support though :slight_smile:

Hi Jorgen,

What happens if you revert/flip all the curves in the input.
It could be that will revert the Z direction.

-Willem

Hi Willem,
Try adding just a few points to a document and run meshPatch and you will see that default direction is -Z :slight_smile:
(Now I have flip as default in my script, but I think it would be nice to update this in the core while it is being revisited)

This is in code that is deeper than the MeshPatch stuff. MeshPatch takes all of the input, turns it into a set of 2d points and lines (with side flags) and then calls a function used by the mesher for triangulation. So, while it may be fixable, it would be Dale Lear that would probably do the work. He’s very busy working on the SubD stuff for V7 right now. If it’s consistent and you can just Flip the result that’s going to be the best solution, at least for any time soon.

BY ALL MEANS! LET HIM WORK ON SUB D! :smiley:

I’ll happily use workarounds, no worries!
Will the fix to support open internal curves be included or are you removing that too?

No, the fix for internal curves should remain. I did that first and then added the function overload. Two different commits and I only reverted the latter. If you find that’s not the case when the function overload is gone please let me know.

1 Like

Thanks Tim, I will!
And that is the only function I really needed anyway :slight_smile:

Hi Tim, it seems that the released SR16 doesn’t have the reverted settings for the boundry curve.
Can you please look into this? If so then I need a simple way to pass an emplty curve to the command and I have not figured that out yet, so as of now my TerrainMesh plugin doesn’t work and hangs Rhino :confused:
Thanks for any help!

The commit was reverted for 6.17 but it does not look like it made it into 6.16. I don’t know scripting myself. I asked Pascal and hopefully he will post here. If he doesn’t, Dale should know, he’s out until th 17th though.

Hi Jorgen - can you set your curve variable = None in this case?

myCrv = None

?

OK- I see the context now - I think what you need is a line like this to explicitly tell the script that it is either a curve or a polyline:

patch_thing = Rhino.Geometry.Mesh.CreatePatch.Overloads[IEnumerable[Rhino.Geometry.Polyline], System.Double, Rhino.Geometry.Surface, IEnumerable[Rhino.Geometry.Curve], IEnumerable[Rhino.Geometry.Curve], IEnumerable[Rhino.Geometry.Point3d], System.Boolean, System.Integer ](myPolyline, tol, pull_srf, innerCrv, outerCrv, blnTrim, intDivide)

So you first tell Rhino what object types to look for in each argument and then hand it the arguments - the one called myPolyline can then be null.

I think.

-Pascal

I dont know… I really don’t understand how to simply define a curve and set it to None… :expressionless:
What would this code look like for it to work on both this latest SR and the previous one?


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)

And Tim wrote that after talking to Steve they removed “the overload that takes a Curve” so now it requires a polyline, but should it not accept “None” as before?

None the less I need a code that works for both previous an current SR’s :slight_smile: