Finding Rhinopython command equivalent

Hi everyone,

I have some queries regarding Rhinopython commands.

In most cases, I am able to find the Rhinopython equivalent of the Rhino commands (or option from Rhino toolbars) based on the name of the command but not in some cases.

Could someone please help me out in getting the command for these 2 cases?

  1. Arc: start, end, direction at start

  2. Rebuild surface UV option.
    image

  3. Also is there any provision to set the U,V discretization of Network curve surface while calling the AddNetworkSurf command itself rather than pursuing the “Rebuild surface UV” option in Rhino?

Regards,

Are you dealing with rhinoscriptsyntax or RhinoCommon?

A quick search turns up these rhinoscriptsyntax methods (most can be found on that page):
http://developer.rhino3d.com/api/RhinoScriptSyntax/#curve-AddArcPtTanPt
http://developer.rhino3d.com/api/RhinoScriptSyntax/#surface-RebuildSurface

In RhinoCommon it’s
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Arc__ctor_5.htm
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Surface_Rebuild.htm

1 Like

Hi @qythium,

Thanks a lot. This was exactly what I was looking for. I am dealing with rhinoscriptsyntax and trying to use that as far as possible. But Rhinocommon solutions are also workable with.

By any chance, do you know how to set the options for the RebuildSurface command?

Say, I want to set Type = Loose or Tight instead of Uniform, how would I implement that in Rhinopython?

Hmm, I’m not 100% sure about this - closest thing I can find is Loft surfaces, which I believe is what the Rhino command is doing under the hood… that is a 2-step process, first extracting the number of isocurves you specify in the U/V direction, then lofting them together with the loft type options.

http://developer.rhino3d.com/api/RhinoScriptSyntax/#surface-AddLoftSrf
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_CreateFromLoftRebuild.htm

1 Like

You might just use Surface.Rebuild.

– Dale

I linked to that above too, but it doesn’t have any overloads corresponding to the Type = Uniform / Tight / Loose etc. options avaliable in the Rhino command.

Hi @qythium,

Sorry, I didn’t notice the “UV” in “RebuildUV.”

There is no SDK function for this. However, as you’ve described, it’s really just a loft operation.

https://mcneel.myjetbrains.com/youtrack/issue/RH-46891

– Dale

Hi @qythium,

Thanks for the idea. However, I am still having some trouble figuring out Rhinocommon implementation.

obj=Rhino.Geometry.Brep.CreateFromLoftRebuild(curves,start=None, end=None, loftType = 1, closed=True, rebuildPointCount = 0)

is giving an error “Message: expected IEnumerable[Curve], got tuple”.

What is the right way to implement methods of Rhino.Geometry in Rhinopython especially I do not want to activate some arguments? I know this is more of a python question than a Rhino question but any help would be great!

@dale,

Does the link mean you are attempting to add that functionality to the SDK?

Could you please inform in the forum if that is done and what kind of update is required to use that?

Thanks in advance.

Yes, I’ve added a new Surface.RebuildOneDirection method to RhinoCommon. You’ll see it in Rhino 6 SR7. See the YouTrack link for an example of it’s usage.

– Dale

1 Like

Hi @dale,

Could you please tell how to update the Rhinocommon version?

I tried doing “Check for Updates”
image and it says this.

But when I copy pasted your code in Rhinopython script, I got the following error:

@Rhino_Gandalf SR7 has not been released yet.

@Helvetosaur,

Oh…Thanks for the info.

@dale

Could you guide me on where to see examples on Rhinocommon implementation?

As with other programming languages, by default values are passed in order into a method/function.

Arguments that have an ‘=’ such as start=None are optional, if values are not passed to those they will take on the default value (what comes after the ‘=’). All required arguments have to be listed first.

Rhino.Geometry.Brep.CreateFromLoftRebuild(curves,start=None, end=None, loftType = 1, closed=True, rebuildPointCount = 0)

In this case ‘curves’ is the only required argument to pass a value to. All the others are optional.

It is also possible to reference arguments specifically by name and thus not have to specify all of them. So it’s possible to use

Rhino.Geometry.Brep.CreateFromLoftRebuild(curves, rebuildPointCount = 5)

which means you pass a list of curves (required) and you accept all the other default values except for rebuildpointcount, which you set to 5 instead of the default 0.

The RhinoCommon API docs for the method specify what it expects for each argument as well as what it returns.

This probably means you didn’t pass a list of curves as the first argument, you passed a tuple (of something) which it wasn’t able to interpret.

Most of the syntax stuff can be picked up from a basic python book or online learning resource (highly recommended); for RhinoCommon specific stuff, there are the guides and samples on the API doc/guide pages…


1 Like

@Helvetosaur,

Thank you very much for the detailed explanation and pointing me to the relevant resources.

I will refer online the docs that you have provided.

Also on further search, it seems like a similar error was discussed here although I that doesn’t seem to solve my problem.

I just gave my curve list as:
curves = (Line1,Line2,Line3,Line4)
obj=Rhino.Geometry.Brep.CreateFromLoftRebuild(curves,start=None, end=None, loftType = 1, closed=True, rebuildPointCount = 1)

Here as you had mentioned, I tried avoiding the default value case and I got the error as this command takes exactly 6 inputs.

Also I tried entering in the .NET format based on one of the inputs in the discussion although I am not sure if I entered it correctly.
geomBaseList = ListLine1,Line2,Line3,Line4
obj=Rhino.Geometry.Brep.CreateFromLoftRebuild(geomBaseList,start=None, end=None, loftType = 1, closed=True, rebuildPointCount = 1)
and I still got an error which said: “expected Type, got Guid”

Hi @Rhino_Gandalf,

Let me know if this help helps:

import Rhino
import scriptcontext
import System

def TestCreateFromLoftRebuild():
    
    p0 = Rhino.Geometry.Point3d(0,0,0)
    p1 = Rhino.Geometry.Point3d(0,10,0)
    l0 = Rhino.Geometry.LineCurve(p0, p1)    
    
    p0 = Rhino.Geometry.Point3d(5,0,5)
    p1 = Rhino.Geometry.Point3d(5,10,5)
    l1 = Rhino.Geometry.LineCurve(p0, p1)    
    
    p0 = Rhino.Geometry.Point3d(10,0,0)
    p1 = Rhino.Geometry.Point3d(10,10,0)
    l2 = Rhino.Geometry.LineCurve(p0, p1)    
    
    crvs = System.Array[Rhino.Geometry.Curve]([l0, l1, l2])
    unset = Rhino.Geometry.Point3d.Unset
    ltype = Rhino.Geometry.LoftType.Normal
    breps = Rhino.Geometry.Brep.CreateFromLoftRebuild(crvs, unset, unset, ltype, False, 8)
    if breps:
        for b in breps:
            scriptcontext.doc.Objects.AddBrep(b)
        scriptcontext.doc.Views.Redraw()
    
TestCreateFromLoftRebuild()    

– Dale

1 Like

Hi @dale,

Thanks a lot. This makes a lot of sense.

Does this mean that the points and lines created should be only using Rhino.Geometry Methods?
Just checking as when I tried using the curves created using Rhinoscriptsyntax, I got the error “expected Curve, got Guid”

Line1=rs.AddLine(P1,P2)
Line2=rs.AddLine(P2,P3)
Line3=rs.AddLine(P3,P4)
Line4=rs.AddLine(P4,P1)
crvs = System.ArrayRhino.Geometry.Curve
unset = Rhino.Geometry.Point3d.Unset
ltype = Rhino.Geometry.LoftType.Loose
breps = Rhino.Geometry.Brep.CreateFromLoftRebuild(crvs, unset, unset, ltype, False, 8)
if breps:
for b in breps:
scriptcontext.doc.Objects.AddBrep(b)
scriptcontext.doc.Views.Redraw()

Hi @Rhino_Gandalf,

The rhinoscryptsyntax methods are document-centric. That it, the methods work on document object - hence the error indicating a guid was expected.

If you want to work on stuff not in the document - in this case creating a lofted surface from curve you create on the fly - you will need to use RhinoCommon (e.g. the Rhino name space).

– Dale

1 Like

Hi @dale

Thank you very much for the clarification. That helps a lot.

Regards,