Hi,
I'm just trying to create some different commands to learn objectARX.
Here, I found a function using ssget and ->erase() to delete the selected entities. It does delete the the entities. But After I run this command and delete the entities if I undo, the deleted entities remain deleted while everything else I did will undo.
Ex:- I create a rectangle > create a circle, move the circle and call the delete function and select the rectangle and delete. - the rectangle is deleted.
Then I undo, message I get in commandline -> "_U FDEL" - but the rectangle is still deleted. (fdel being the command name)
Undo again, message I get -> "_U MOVE" - but the rectangle is still deleted.
So the rectangle is gone permanently.
How do I fix this?
Below is the function
void deleteEntity()
{
ads_name ssname;
acedSSGet(NULL, NULL, NULL, NULL, ssname);
Adesk::Int32 number = 0;
if ((acedSSLength(ssname, &number ) != RTNORM) || (number == 0))
{
acedSSFree ( ssname );
}
ads_name ent;
AcDbObjectId id = AcDbObjectId::kNull;
for (long i = 0; i < number; i++)
{
acedSSName(ssname, i, ent) != RTNORM;
acdbGetObjectId(id, ent);
AcDbEntity * pEnt = NULL;
acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite);
pEnt->erase ();
}
acedSSFree(ssname);
ads_regen();
}
Thanks in advance for any help.
Solved! Go to Solution.
Solved by daniel_cadext. Go to Solution.
After calling pEnt->erase (); make sure you call pEnt->close(); things may get wonky if it's left open for write
Can't find what you're looking for? Ask the community or share your knowledge.