Void Function

Hi guys, i’m having an problem to call an function in my plugin, i’ll add the sample here.

CRhinoScriptCommand::result CCommandSalvarPontos::RunCommand( const CRhinoCommandContext& context )

	int contador = 0;
	long int tipo,v,nobj;
	double d0,d1;
  CRhinoApp& pApp=RhinoApp();
  CRhinoDoc * doc=pApp.ActiveDoc();

  CRhinoGetPoint gp;
  gp.SetCommandPrompt( L"Desenhe um Quadrado para obter os objetos" );
  gp.SetGetPointCursor( RhinoApp().m_default_cursor );
  CRhinoGet::result res = gp.Get2dRectangle( 0, 0, FALSE, PS_DOT );
  if( res != CRhinoGet::rect2d )
    return failure;

  CRect rect = gp.Rectangle2d();
  CRhinoView* view = gp.View();

  CRhinoPickContext pick_context;
  pick_context.m_go = 0;
  pick_context.m_view = view;
  pick_context.m_pick_style = CRhinoPickContext::window_pick;
  pick_context.m_bPickGroups = true;
  switch( view->Viewport().DisplayMode() )
    case ON::shaded_display:
    case ON::renderpreview_display:
      pick_context.m_pick_mode = CRhinoPickContext::shaded_pick;

  CRhinoObjRefArray list;
  int count = 0;
  if( view->Viewport().GetPickXform(rect, pick_context.m_pick_region.m_xform) )
    POINT point = rect.BottomRight();
    view->ActiveViewport().VP().GetFrustumLine( point.x, point.y, pick_context.m_pick_line );
    int i, count = context.m_doc.PickObjects( pick_context, list );
    for( i = 0; i < count; i++ )
      const CRhinoObject* obj = list[i].Object();
      if( obj && obj->IsSelectable() )

		 SalvarPontos(obj); //problem is here, it say's i have to make an pointer to this.
        obj->Select( true );
    if( count )
  return success;

  return CRhinoScriptCommand::success;

#pragma endregion

// END SalvarPontos command
ON_3dPointArray listapontos;

void SalvarPontos( const CRhinoObject * obj )
	ON_3dPoint pta,pt,centro;
	long int tipo,v;
	double * nos,d0,d1;
	int nconti,loc;
	bool arco;

	CRhinoApp& pApp = RhinoApp();
	CRhinoDoc * doc = pApp.ActiveDoc();


	tipo = obj->ObjectType();
	if (tipo == 1) //Ponto
		const ON_Point * ppb = ON_Point::Cast(obj->Geometry());
		pta = ppb->point;
	if (tipo == 4) //curva
	double tt,cv;
	const ON_Curve * curva = ON_Curve::Cast(obj->Geometry());
	ON_NurbsCurve * ncurva = curva->NurbsCurve();


	ncurva->GetDomain(&d0, &d1);
	cv = ncurva->CVCount();
	for ( v = 0; v < cv; v++)
		tt = ncurva->GrevilleAbcissa(v);
		pt = curva->PointAt(tt);

So i need it like this, cause after i’ll have to call others void functions to my plugin so if u can help me with that i’ll appreciate ur help, sorry my poor english.

Edited the OP for tripple backtick enclosure of code.

@dale can u help me with this?

Hi @altemir.henrique,

The standard object picker will do windows and/or crossing selection. So there shouldn’t be a reason to use a pick context, unless I don’t understand what you are trying to do.

There is a simpler example of what I think you are trying to do.

CRhinoCommand::result CCommandTest::RunCommand(
  const CRhinoCommandContext& context
  CRhinoGetObject go;
  go.SetCommandPrompt(L"Select points and curves");
  go.GetObjects(1, 0);
  if (go.CommandResult() != CRhinoCommand::success)
    return go.CommandResult();

  ON_3dPointArray points;
  for (int i = 0; i < go.ObjectCount(); i++)
    const CRhinoObjRef& objref = go.Object(i);

    const ON_Point* point = objref.Point();
    if (nullptr != point)

    const ON_Curve* curve = objref.Curve();
    if (nullptr != curve)
      ON_NurbsCurve nurb;
      if (curve->GetNurbForm(nurb))
        ON_SimpleArray<double> grev(nurb.CVCount());
        if (nurb.GetGrevilleAbcissae(grev.Array()))
          for (int g = 0; g < grev.Count(); g++)

  for (int i = 0; i < points.Count(); i++)


  return CRhinoCommand::success;

– Dale

Hi @dale thanks for ur reply, so i’ll try to explain better what i’m trying to do with that plugin.

I need to make an select window from the plugin and i’ll need to take all objects inside of it, after i’ll make they become curves and NURBSCurves, so i’ll get all the points on it and save they in a array of points.

And to be more clear, this sample is working if i wont make the void function, but my boss want me to use it, because after this i’ll have to take others void functions from another .h, so i want to know how to call my void function that i’ve declared under the code of the window selecting. I think my problem here is not the CRhino commands and it’s more C commands, so if u can help me with that i’ll be really greatfull to u.

If i not have let the things clear please tell me and i’ll try to explain it better.

  • Altemir

CRhinoGetObject allows the user to select object either by: 1.) Windows, 2.) Crossing, or 3.) Picking. Try running the sample I posted above. When prompted to select, just drag a window.

I have no idea what this means - sorry.

– Dale

Hi @dale i’ve found the problem, thanks for ur help.


Hi @dale i’ve a new question to do, just think like this, i’ve an array of points of n size, and i need to calculate the median of that points in the array, any ideas of how i can do it?

Hi @altemir.henrique,

Are you looking for a statistical median? Or something else, such as the centroid?

– Dale

Hi @dale, i think i’ll need the centroid, because after i got this i’ll need to draw a line with it.

Hi @altemir.henrique,

Maybe this is all you need?

ON_3dPointArray points;
// Add points to array here...
ON_3dPoint center = points.BoundingBox().Center();

– Dale

@dale that was exactly what i want, thanks a lot for that, i’m still learning the Rhino SDK c++ so there is a lot of commands i’m still wont know about, again thank you!