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

Entities invisible in RENDER after handOverTo()

7 REPLIES 7
Reply
Message 1 of 8
tbrammer
581 Views, 7 Replies

Entities invisible in RENDER after handOverTo()

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.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

7 REPLIES 7
Message 2 of 8
moogalm
in reply to: tbrammer

Hi, 

 

Interesting, is it possible for you send a sample usable code for reproducing the behavior, I would like to investigate further.

 

 

Message 3 of 8
tbrammer
in reply to: moogalm

I need to create a small app that shows the effect.

I will to as soon as time permits.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 8
tbrammer
in reply to: moogalm

I need to create a small app that shows the effect.

I will do as soon as time permits.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 5 of 8
tbrammer
in reply to: tbrammer

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:

  1. Build the project, start AutoCAD and load imoshandover.arx
  2. Open scene.dwg
  3. RENDER the scene. It contains a green box, a red "double-sphere" and a blue region. The rendering looks OK
  4. Call MYCOMMAND, select the region - it will be rotated by 10°.
  5. RENDER the scene again. --> The region disappeared!

There is nothing wrong with cmdTestHandOver(). Try this:

  1. Open scene.dwg
  2. Call MYCOMMAND and select any entity - as many times as you want.
  3. RENDER the scene --> The rendering looks OK.
  4. Call MYCOMMAND and select any entity
  5. RENDER the scene again. --> The entity disappeared!

I've created scene.dwg from scratch. The same should happen with any other drawing.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 8
moogalm
in reply to: tbrammer

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();
		}
	}
Message 7 of 8
tbrammer
in reply to: moogalm

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.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 8 of 8
moogalm
in reply to: tbrammer

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.

 

http://autode.sk/2myHbrJ

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

Post to forums  

Autodesk Design & Make Report

”Boost