I have a module that creates an AcDbRegion which represents the floor of a room. I store the floor's object ID and want to keep it unchanged.
When the room geometry changes I update the floor by creating a new AcDbRegion *pNewFloor with the new geometry and replacing the old region with the new one using pOldFloor->handOverTo(pNewFloor). This works fine - until I use the command RENDER: After the first update with handOverTo() the floor disappears from the image that RENDER creates. It seems that RENDER can't deal with the fact that the old objectID points to a different entity.
Is this a known problem? Is there something I can do to make RENDER accept the change?
As workaround I changed my code to pOldFloor->copyFrom(pNewFloor) which works fine too. Anyway I would like to know how to fix the handOverTo() approach.
Hi,
Interesting, is it possible for you send a sample usable code for reproducing the behavior, I would like to investigate further.
Here we go...
I have attached a very small and simple ARX project in handover.zip. It implements the command MYCOMMAND.
If you call MYCOMMAND you will be prompted to select an entity. This entity pEnt will be copied using pEnt->getTransformedCopy(xform, pEntNew). Than pEntNew is handed over to pEnt. See void cmdTestHandOver() in acrxEntryPoint.cpp.
To reproduce the effect:
There is nothing wrong with cmdTestHandOver(). Try this:
I've created scene.dwg from scratch. The same should happen with any other drawing.
Hi,
Thanks for providing sample code, I can recreate the behavior.
I suspect 3DGS graphics needs a refresh after replacing handle on Non-Database object.
Can you please call pEnt->draw() after the handOverTo function completes.
void test14() { ads_point pt; ads_name ent; AcDbObjectId objId; if (acedEntSel(_T("\nSelect an entity: "), ent, pt) != RTNORM) return; if (acdbGetObjectId(objId, ent) != Acad::eOk) //ads_name-->AcDbObjectId return; AcGeMatrix3d xform; Acad::ErrorStatus es; AcDbEntity *pEnt = 0, *pEntNew = 0; if ((es = acdbOpenObject(pEnt, objId, AcDb::kForRead)) == Acad::eOk) { AcDbExtents ext; pEnt->getGeomExtents(ext); AcGePoint3d center(ext.minPoint() + 0.5*(ext.maxPoint() - ext.minPoint())); double phi = 10 * M_PI / 180; //10� xform.setToRotation(phi, AcGeVector3d::kZAxis, center); // Rotate by 10� around the center es = pEnt->getTransformedCopy(xform, pEntNew); es = pEnt->upgradeOpen(); es = pEnt->handOverTo(pEntNew); acutPrintf(L"\nhandOverTo() returned %s", acadErrorStatusText(es)); if (es == Acad::eObjectToBeDeleted) { // Success delete pEnt; pEnt = pEntNew; /*pEnt->draw();*///refresh for entity graphics*/ acutPrintf(L"\nGood. Now call RENDER!\n"); } else { // Fail delete pEntNew; } pEnt->close(); } }
I tried calling pEnt->draw() - but it had no effect. Did you try it yourself? Did it work on your side?
I also tried to call pEnt->recordGraphicsModified() before and after the handOverTo(). Also no effect.
See the bold lines of code below. I think I should do pEnt->downgradeOpen() before pEnt->draw(), right? But it doesn't make a difference.
//pEnt->recordGraphicsModified(); // No effect es = pEnt->handOverTo(pEntNew); acutPrintf(L"\nhandOverTo() returned %s", acadErrorStatusText(es)); if (es==Acad::eObjectToBeDeleted) { // Success delete pEnt; pEnt = pEntNew; //pEnt->recordGraphicsModified(); // No effect //es = pEnt->downgradeOpen(); // No effect pEnt->draw(); // As suggested by madhukar.moogala (Autodesk Support) acutPrintf(L"\nGood. Now call RENDER!\n"); }
I was wondering whether the effect will also show up if the entities involved are of different classes. So I've created pEntNew as an entity of a different class like this:
if (AcDb3dSolid::cast(pEnt)) es = pEnt->getTransformedCopy(xform, pEntNew); else { AcDb3dSolid *pSolid = new AcDb3dSolid(); pSolid->setPropertiesFrom(pEnt); pSolid->createSphere(vRad.length()); AcGeMatrix3d trans; trans.setToTranslation(center.asVector()); es = pSolid->transformBy(trans); pEntNew = pSolid; }
This way my blue region is handed over to a new blue sphere. This new sphere does also disappear in the rendering.
I agree with you - it seems to be some kind of GS "issue". I think there is no real need to use handOverTo() with entities that are visible in a rendering.
I'm perfectly happy with using copyFrom() instead of handOverTo() because I don't change the entity class.
I believe re-drawing entity graphics may not really refreshing graphics as I thought, can check with sending REGEN3 ?
But it is working at my end.