Hi there i’m knocking my head again the wall for two days now trying to isolate this glitch in my code… but i got a nice picture lol !
i pick 3d CV point on a surface move those point 3 times fine every thing work has intended,
finally i put this code in a function for avoiding repeating lines of code and then the function
break after one success move and write 2 more glitched point (the two remaining) in the document
(the first one is write where it expected to be) you can see the two other (glitch ghosted) if you rectangle selection at the location…
@Dale if you can help me on this that would be awesome it’s just those details where everything
is just not perfect as it should that turn me mad…
you may have quick explanation for that what i’m doing wrong?
void Mv(CRhinoObject* GripsOwner, CRhinoObject* newObj, int CVindex, ON_3dPoint destination, const CRhinoCommandContext& context) {
GripsOwner->EnableGrips(1);
GripsOwner->m_grips->m_grip_list[CVindex]->MoveGrip(destination);
newObj = GripsOwner->m_grips->m_grip_list[CVindex]->m_grip_owner->NewObject();
context.m_doc.ReplaceObject(CRhinoObjRef(GripsOwner), newObj, true);
GripsOwner = newObj;
context.m_doc.Redraw();
}
CRhinoCommand::result CCommandaTest18::RunCommand(const CRhinoCommandContext& context)
{
CRhinoGetObject go;
go.SetGeometryFilter(CRhinoGetObject::grip_object);
go.SetCommandPrompt(L"Select Ctrlpt:");
go.GetObjects(3, 3);
if (go.CommandResult() == CRhinoCommand::cancel) {
return cancel;
}
int count = go.ObjectCount();
ON_wString msg;
msg.Format(L"----->%d\r\n", count);
RhinoApp().Print(msg);
CRhinoGripObject* GripList = new CRhinoGripObject[count];
CRhinoObjRef* GripRef = new CRhinoObjRef[count];
ON_3dPoint* ptlist = new ON_3dPoint[count];
int* CVindex = new int[count];
CRhinoObject* newObj = nullptr;
for (int i = 0; i < count; i++)
{
GripRef[i] = go.Object(i);
CRhinoObject* obj = const_cast<CRhinoObject*> (go.Object(i).Object());
GripList[i] = *CRhinoGripObject::Cast(obj); // Copy a real rhino Object ivalue Grips.
ptlist[i] = GripList[i].m_base_point; // *1 collect data point base point.
CVindex[i] = GripList[i].m_grip_index; // *2 collect index.
}
CRhinoObject* GripsOwner = GripList[0].Owner();
GripsOwner->EnableGrips(1);
for (int i = 0; i < count; i++)
{
GripsOwner->m_grips->m_grip_list[CVindex[i]]->MoveGrip(ON_3dPoint(5, 5, 5 + i));
newObj = GripsOwner->m_grips->m_grip_list[CVindex[i]]->m_grip_owner->NewObject();
context.m_doc.ReplaceObject(CRhinoObjRef(GripsOwner), newObj, true);
GripsOwner = newObj;
}
context.m_doc.Redraw();
if (GripsOwner) {
RhinoApp().Print("Object is ok.");
}
for (int i = 0; i < count; i++)
{
GripsOwner->m_grips->m_grip_list[CVindex[i]]->MoveGrip(ON_3dPoint(10, 10, 5 + i));
newObj = GripsOwner->m_grips->m_grip_list[CVindex[i]]->m_grip_owner->NewObject();
context.m_doc.ReplaceObject(CRhinoObjRef(GripsOwner), newObj, true);
GripsOwner = newObj;
}
context.m_doc.Redraw();
if (GripsOwner) {
RhinoApp().Print("Object is ok Step2");
}
for (int i = 0; i < count; i++)
{
GripsOwner->m_grips->m_grip_list[CVindex[i]]->MoveGrip(ON_3dPoint(15, 15, 5 + i));
newObj = GripsOwner->m_grips->m_grip_list[CVindex[i]]->m_grip_owner->NewObject();
context.m_doc.ReplaceObject(CRhinoObjRef(GripsOwner), newObj, true);
GripsOwner = newObj;
}
context.m_doc.Redraw();
if (GripsOwner) {
RhinoApp().Print("Object is ok Step3");
}
for (int i = 0; i < count; i++)
{
Mv(GripsOwner, newObj, CVindex[i], ON_3dPoint(20, 20, 5 + i), context);
if (GripsOwner) {
RhinoApp().Print("Object is ghosted in step 4 ghost point are present in doc at ON_3dPoint(20, 20, 5 + i)");
}
}
return CRhinoCommand::success;
}