Rotation of different surfaces that conform an object

Hello, I am trying to select different surfaces and then try to rotate them along an axis, but I can’t achieve it because in order to rotate, I need to assign a different object name to each object. The number of surfaces selected can vary. I am using Rhino 5 and visual Studio 2010.

CRhinoGetObject go;
	
	go.SetCommandPrompt( L"Select surfaces" );
	go.SetGeometryFilter( CRhinoGetObject::surface_object );
	go.GetObjects( 1, 0 );
	if( go.CommandResult() != success )
		return go.CommandResult();
	// Validate selection


	const CRhinoObjRef& obj_ref = go.Object(2);
	const CRhinoObject* obj = obj_ref.Object();

	if ( go.Result() == CRhinoGet::object )

	{ 
		int i, object_count = go.ObjectCount();
		for ( i = 0; i < object_count; i++ )
		{ 
			const CRhinoObjRef& obj_ref = go.Object(0);
			const CRhinoObject* obj = obj_ref.Object();
		}
	}

	ON_wString prompt("");
	prompt.Format( L"Number of selected surfaces: %d \n", go.ObjectCount());
	RhinoApp().Print( prompt );

	CRhinoGetObject go1;
	
	go1.SetCommandPrompt( L"Select border" );
	go1.SetGeometryFilter( CRhinoGetObject::curve_object );
	go1.GetObjects( 1, 1 );
	if( go1.CommandResult() != success )
		return go1.CommandResult();
	const CRhinoObjRef& refBord = go1.Object(0);
	const CRhinoObject* obj_bord = refBord.Object();
	const ON_Curve* border = refBord.Curve();
	if( !border )
		return failure;

	ON_3dVector axis_normal(1, 0, 0);
        ON_3dPoint lowP(0, 0, 0);
	ON_Xform xform;
	xform.Rotation(-1*0.53,axis_normal,lowP);
	//we rotate the angle
	const CRhinoObjRef refSurf_new = context.m_doc.TransformObject(obj, xform, true, true, true);
	const ON_Surface* srf_new = refSurf_new.Surface();
	const CRhinoObjRef refbord_new = context.m_doc.TransformObject(obj_bord, xform, true, true, true);
	const ON_Curve* border_new = refbord_new.Curve();

	context.m_doc.Redraw();
		
	return CRhinoCommand::success;

Hi @f.leon.marquez95,

I am not sure I completely understand what you want. But take a look at the attached and see if I am close.

cmdTestLeon.cpp (3.5 KB)

– Dale

1 Like