How to let user pick a vertex point on a brep?

Hi guys,
I thought it is very simple and straight forward, but I am stuck here. I want to let user pick two vertex point on a brep solid. It may not be that simple. Could anyone please help me how to do that in this case?
I have checked chatgpt, it gives me a complex code, I don’t like it. I think it should a very simple code. Here I have this:
const CRhinoObjRef& objref1 = go1.Object(0);

Now how can I get the point from objref1 which is a vertex point?

Thank you.
John

Hi @smartunfold :
May be you need to do like this.

    CRhinoDoc* doc = context.Document();
	if (nullptr == doc)
		return CRhinoCommand::failure;

	CRhinoGetObject go;
	go.SetCommandPrompt(L"Select Object");
	go.SetGeometryFilter(CRhinoGetObject::surface_object | CRhinoGetObject::polysrf_object | CRhinoObject::extrusion_object);
	go.GetObjects(1, 1);
	if (go.CommandResult() != CRhinoCommand::success)
		return go.CommandResult();

	const ON_Brep* brep = go.Object(0).Brep();
	if(nullptr == brep)
		return CRhinoCommand::failure;

	CRhinoGetPoint gp;
	gp.SetCommandPrompt(L"Pick Point");

	gp.Constrain(*brep);//Lock Point On Brep

	gp.GetPoint();
	if (gp.CommandResult() != CRhinoCommand::success)
		return gp.CommandResult();

	ON_3dPoint origin = gp.Point();
	return CRhinoCommand::success;

…you can do so by custom geometry filter

you have to check the componentindex componentindextype in the filter to see if it is a brep vertex.

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.componentindextype

not sure if there is a simpler approach.

happy coding - kind regards -tom

1 Like

thank you. I have changed my codes so I can avoid this issue. Thank you very much.