like the title mentioned above,
If i want to auto-modify the entity newly appended to db, i.e for newly appended entity ,I want to change it's colorIndex to 0;
or according to the type of the entity,for AcDbline I change the length,for circle ,I change the radius.
I know for catching every entity appended Msg I can use the AcDbDatabaseReactor subclass.
and override
virtual void objectAppended(const AcDbDatabase* dwg, const AcDbObject* dbObj);
But the in that callback function, dbObj is read-only.
So can you help me ??
Solved! Go to Solution.
Solved by owenwengerd. Go to Solution.
Hi,
The following code will help you:
if(dbObj->isWriteEnabled() || dbObj->upgradeOpen() == Acad::eOk) { //your code here... }
Regards,
Jonathan
thank you first!
but it's doesn't work!
virtual void objectAppended(const AcDbDatabase* dwg,
const AcDbObject* dbObj);
dbObj is const AcDbObject*.
in objectAppended function, dbObj->isWriteEnabled() always return false and dbObj->upgradeOpen() is used on no-const object .
So const AcDbObject* dbObj must cast to no-const one. but this fill abort the autoCAD.
Yes, you're right. I tried something not very clean (i.e. C cast):
...::objectAppended(...) { if(dbObj->isKindOf(AcDbPolyline::desc())) myFunction((AcDbPolyline *)dbObj); }
Another approach is to store the object ids in objectAppended and treat the list of your ids when commandEnded.
You have to choose a later context to perform your modifications. The typical pattern is to use the reactor to gather and store the object ids of objects you're interested in, then perform your processing on the objects later, perhaps in a different reactor.
@owenwengerd wrote:You have to choose a later context to perform your modifications. The typical pattern is to use the reactor to gather and store the object ids of objects you're interested in, then perform your processing on the objects later, perhaps in a different reactor.
I guess your answer is right, but in *what another reactor* to to processing on the objects later? if I want to modify the newly appended entity at once.