Hello there,
I’ve to create a Rhinoceros plugin for work. So i’m trying to get used to manipulate object though SDK.
My actual objective is simply to move a point by adding values to his position.
So my problem is that I cannot find a way to:
-modify the getted point
-print a new point
Let’s see what my code looks like :
CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context )
{
// How much i want to move the point …
double xMove = 1.0;
double yMove = 1.0;
double zMove = 1.0;
.
CRhinoGetObject second;
second.SetCommandPrompt( L"Select a point" );
.
CRhinoGet::result something = second.GetObjects(1, 1);
if(second.CommandResult() != CRhinoCommand::success) return second.CommandResult();
.
.
const CRhinoObject* obj = second.Object(0).Object();
if(!obj) return CRhinoCommand::failure;
.
const ON_Point& pt = CRhinoPointObject::Cast(obj)->Point();
.
.
ON_Point newOne(pt.point.x + xMove, pt.point.y + yMove, pt.point.z + zMove); // new location
.
// would like do to something like CRhinoPointObject::Cast(obj)->SetPoint(newOne);
// but try to create new point :
CRhinoPointObject testytest;
if(!testytest.IsValid()) ::RhinoApp().Print(L"Oops! “); // print this … Don’t understand why
.
ON_UUID uuid = testytest.Attributes().m_uuid;
ON_UuidToString( uuid, str );
::RhinoApp().Print(L"ID: "%s", “, str); // give 000000000…
.
testytest.SetPoint(newOne); // seems work because:
::RhinoApp().Print(L” position: ‘%.2f’, ‘%.2f’, ‘%.2f’.\n”,
newOne.point.x, newOne.point.y, newOne.point.z); // give new position
.
// tried:
// testytest.CopyFrom(CRhinoPointObject::Cast(obj));
// testytest.SetPoint(newOne);
.
.
// do nothing ?
// testytest.Draw(second.View()->ActiveViewport());
// ON_Xform pff;
// second.View()->ActiveViewport().DrawRhinoObject(&testytest, pff);
// testytest.Draw(second.View()->ActiveViewport());
.
context.m_doc.Redraw(); // assume i have to do this at the end
.
return CRhinoCommand::success;
}
Thank you in advance