RhinoCommon equivalent to Blend command


#1

Hi, I would like to know what is the RhinoCommon method that is equivalent to the Blend command in Rhino? I mean the Blend command used to create a curve connecting two curves (the “quick” version). I initially thought it was Curve.CreateBlendCurve, but after trying a while, I can’t produce the same curve. That method produces a curve more like the Connect command. I want a smooth, curvature-continuous curve like the one the Blend does.
Can someone help me?
Thanks,
Ilidio.


(Dale Fugier) #2

Hi Ilidio,

Currently the only API available for blending between curves is what is provided by Curve.CreateBlendCurve. And yes, it is known not to product the same results as Rhino’s BlendCrv command.

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

Is there a reason you prefer one result over the other?

– Dale


#3

Hi Dale,
Thanks for answering. Yes, I prefer the Blend curve because it is more continuous (at least in my case). The curve produced by Pthon has a kind of “kink” in it. It is not a real discontinuity, but the curve change direction in a strange way. I will try to create a clean example (can we attach files on the forum?).

I was thinking… may the bulge parameter has something to do with it? Do ou know what does this parameter means?

Thanks a lot,

Ilidio.


(Dale Fugier) #4

What ‘bulge’ parameter? What a I missing?

– Dale


#5

I mean this overload:

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_Curve_CreateBlendCurve_1.htm

It expects two double parameters named bulgeA and B…


(Dale Fugier) #6

Hi Ilidio,

I am not familiar with the Curve.CreateBlendCurve that takes “bulge” parameters as input.

I am having good success in creating blends with the Curve.CreateBlendCurve that require to you specify the continuity. Have you tried these?

– Dale


#7

Hi,
Yes, I am using the same one. I asked about bulge because I saw the overload.
Take a look on image below:

The original curves are in red. The red curves on the left are identical to the ones on the right. In yellow (selected) there are the generated blend curves.
The left one is generated by Rhino Blend command. The right one was generated by CreateBlendCurve. Can you see they are slightly different? I prefer the left one.

Here is the program I used if you want to try for yourself…

import Rhino
import Rhino.Geometry.Point3d as Point3d
import Rhino.Geometry.Vector3d as Vector3d

doc = Rhino.RhinoDoc.ActiveDoc
doc.Objects.UnselectAll()
doc.Views.Redraw()

getter = Rhino.Input.Custom.GetObject()
getter.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
getter.SubObjectSelect = False
getter.GroupSelect = False

getter.SetCommandPrompt("Give curves")

rt = getter.GetMultiple(1,0)
if rt == Rhino.Input.GetResult.Cancel:
    pass
if getter.ObjectCount == 0:
    print trl("no curve selected")
else:
    l = getter.Objects()
    l = [oref.Curve() for oref in l]
    cont = Rhino.Geometry.BlendContinuity.Curvature
    blend_crv = Rhino.Geometry.Curve.CreateBlendCurve(l[0],l[1],cont)
    doc.Objects.Add(blend_crv)

doc.Views.Redraw()

(Dale Fugier) #8

Hi Ilidio,

This version of CreateBlendCurve:

CreateBlendCurve(Curve curveA, Curve curveB, BlendContinuity continuity)

simply calls this version, passing it bulge parameters of 1.0:

CreateBlendCurve(Curve curveA, Curve curveB, BlendContinuity continuity, double bulgeA, double bulgeB);

Can you try using this version:

CreateBlendCurve(Curve curve0, double t0, bool reverse0, BlendContinuity continuity0, Curve curve1, double t1, bool reverse1, BlendContinuity continuity1);

Thank you,

– Dale