hi there still bugging on a simple issue…
Why a simple CRhinoGetObject does’ not work while the same code with CRhinoGetPoint work like a charm ? it’s me or the API is bugged ?
( what i want is to select a step by step CRhinoGetObject in controlled order …)
please i need a quick look is it just an API issue ?
My needed Not working Code:
CRhinoGetObject* go;
int ct = 0;
while (ct < 2) {
for (size_t i = 0; i < NumberOfPoint; i++)
{
go = new CRhinoGetObject();
str.Format(L"Select the point number %d in row:%d\r\n", i + 1, ct + 1);
go->SetCommandPrompt(str);
go->SetGeometryFilter(CRhinoGetObject::meshvertex_filter);
CRhinoGetObject::result res = go->GetObjects(0, 1);
if (go->CommandResult() == CRhinoCommand::success) {
ON_3dPoint* pt;
if (ct == 1) {
listpt[i + NumberOfPoint] = go->Point();// i + NumberOfPoint shift the index for storage.
pt = &(listpt[i + NumberOfPoint]);
}
else {
listpt[i] = go->Point();
pt = &(listpt[i]);
}
go->ClearObjects(); // ...
delete go;
str.Format(L"(%lf,%lf,%lf)\r\n", pt->x, pt->y, pt->z);
RhinoApp().Print(str);
}
else {
return CRhinoCommand::failure;
}
}
ct++;
}
Now my full sample Working Code (but not quite why i need):
CRhinoCommand::result CCommandaTest::RunCommand(const CRhinoCommandContext& context)
{
size_t start = 0;
ON_3dPoint listpt[20];
CRhinoObjRef obj[20];
for (size_t i = 0; i < 20; i++)
{
listpt[i] = ON_3dPoint(0, 0, 0);
}
int NumberOfPoint = 0;
ON_wString str;
CRhinoGetNumber gn;
gn.SetCommandPrompt(L"Set the number of points for One Row:\r\n");
gn.GetNumber();
NumberOfPoint = (int)gn.Number();
str.Format(L"The Number: %d\r\n", NumberOfPoint);
RhinoApp().Print(str);
CRhinoGetPoint gp;
int ct = 0;
while (ct < 2) {
for (size_t i = 0; i < NumberOfPoint; i++)
{
str.Format(L"Select the point number %d in row:%d\r\n", i + 1, ct + 1);
gp.SetCommandPrompt(str);
gp.GetPoint();
ON_3dPoint* pt;
if (ct == 1) {
listpt[i + NumberOfPoint] = gp.Point();
pt = &(listpt[i + NumberOfPoint]);
}
else {
listpt[i] = gp.Point();
pt = &(listpt[i]);
}
str.Format(L"(%lf,%lf,%lf)\r\n", pt->x, pt->y, pt->z);
RhinoApp().Print(str);
}
ct++;
}
// Count[0] + Count[1] + Count[2]
for (size_t i = 0; i < 20; i++)
{
str.Format(L"Memory slot: %d 3d point collected %lf %lf %lf\r\n", i, listpt[i].x, listpt[i].y, listpt[i].z);
RhinoApp().Print(str);
}
return CRhinoCommand::success;
}