ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

undo issue using ->erase() to delete an entity

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ShricharanaB
304 Views, 2 Replies

undo issue using ->erase() to delete an entity

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.

Labels (4)
2 REPLIES 2
Message 2 of 3

After calling pEnt->erase (); make sure you call pEnt->close(); things may get wonky if it's left open for write

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 3 of 3
ShricharanaB
in reply to: ShricharanaB

@daniel_cadext That worked!

 

Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report