Hi;
I want to create Helix by c++, it seem use the function RhinoGetHelix() ,but how do I use it ? Who can give me some examples ?
Hi @pythonuser,
How about this?
CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
CArgsRhinoGetSpiral args;
ON_NurbsCurve helix;
CRhinoCommand::result rc = RhinoGetHelix(args, helix);
if (rc == CRhinoCommand::success)
{
context.m_doc.AddCurveObject(helix);
context.m_doc.Redraw();
}
return rc;
}
Note, if you don’t care to use our UI, then just use RhinoCreateSpiral, which returns a NURBS curve. See rhinoSdkGetSpiral.h
for more details.
– Dale
Hi@dale,
It is very helpful, thinks
Hi;
What is the problem in my code, the VS prompt : Error C2665: “RhinoCreateSpiral” : none of the three overloads can convert all parameter classes
CRhinoGetObject go;
go.SetCommandPrompt( L"select curve" );
go.SetGeometryFilter(CRhinoGetObject::curve_object);
go.EnableSubObjectSelect( FALSE );
go.EnableGroupSelect(FALSE);
go.GetObjects( 1, 1 );
if( go.CommandResult() != CRhinoCommand::success )
return CRhinoCommand::cancel;
const ON_Curve* rail = go.Object(0).Curve();
ON_NurbsCurve helix;
CRhinoCommand::result rc = RhinoCreateSpiral(rail,rail->Domain().Min(),rail->Domain().Max(),rail->PointAtStart(),2.4,20,0.5,0.5,12,&helix);
if (rc == CRhinoCommand::success)
{
context.m_doc.AddCurveObject(helix);
context.m_doc.Redraw();
}
return rc;
Hi @pythonuser,
Read the comments for each RhinoCreateSpiral
function carefully, as each requires different input and creates a different type of curve.
Here is an example of creating a helix around a curve:
CRhinoCommand::result CCommandTest6::RunCommand(const CRhinoCommandContext& context)
{
CRhinoGetObject go;
go.SetCommandPrompt(L"Select curve");
go.SetGeometryFilter(CRhinoGetObject::curve_object);
go.SetGeometryAttributeFilter(CRhinoGetObject::open_curve);
go.EnableSubObjectSelect(FALSE);
go.GetObjects(1, 1);
if (go.CommandResult() != CRhinoCommand::success)
return CRhinoCommand::cancel;
const CRhinoObjRef& objref = go.Object(0);
const ON_Curve* curve = objref.Curve();
if (nullptr == curve)
return CRhinoCommand::failure;
CArgsRhinoGetSpiral args;
args.SetAroundCurve(TRUE);
double t, t0, t1, tmid;
objref.CurveParameter(&t);
curve->GetDomain(&t0, &t1);
curve->GetNormalizedArcLengthPoint(0.5, &tmid);
args.SetRail(curve);
// flip rail and t's if necessary
if (t > tmid)
{
args.Rail()->Reverse();
double d = t1; t1 = t0; t0 = d;
}
args.SetStartDir(curve->TangentAt(t0));
args.SetStartPoint(curve->PointAt(t0));
args.SetEndDir(curve->TangentAt(t1));
args.SetEndPoint(curve->PointAt(t1));
double d = ON_UNSET_VALUE;
curve->GetLength(&d);
args.SetLength(d);
args.SetPitchMode(FALSE);
if (args.PitchMode())
args.SetTurns(args.Length() / 2.4);
else
args.SetPitch(args.Length() / 12);
args.SetFirstRadius(0.5);
args.SetSecondRadius(0.5);
ON_NurbsCurve helix;
bool rc = RhinoCreateSpiral(args, helix);
if (rc)
{
context.m_doc.AddCurveObject(helix);
context.m_doc.Redraw();
}
return rc ? CRhinoCommand::success : CRhinoCommand::failure;
}
– Dale
1 Like
Think you very much:grinning: