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

how Can i copy the persistent reactor from Entity to the new Copy?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
806 Views, 5 Replies

how Can i copy the persistent reactor from Entity to the new Copy?

I have a AcDbline in the model-space And I have add a curstomized persistent reactor to it,Now I want to realize that:
When I copy the line ,then make the new line have the same persistent reactor attched to it.

i.e the new persistent reactor class is :



class AsdkObjectToNotify : public AcDbObject
{
virtual void copied(const AcDbObject* dbObj, const AcDbObject* newObj);

};

I have override the copied function ,but found newObj is in read - only state.I cann't make it writeable I have tried.

I have think that May I can use other reactor class to accomplish that

i.e AcEditorReactor ,AcDbDatabaseReactor ...

but found all the function 's paramter is const- qualified. I cann't write the object as parameter.

So will method may help me ?

THANKS!


>>>
I FOUND ARX.chm said
"Transient reactor attachments to the original object are not copied to the new object, but persistent reactor attachments are."

But I have test it,following the above sample, The newly AcDbLine Copy don't copy the original Line's persistent reactor.
5 REPLIES 5
Message 2 of 6
owenwengerd
in reply to: Anonymous

The documentation is correct. You are confusing persistent reactor objects with *references* to persistent reactors (what the documentation refers to as "attachments"), which certainly do get copied.

 

What exactly do you mean by "When I copy the line"? When you call AcDbLine::deepClone()? AcDbLine::wblockClone()? The COPY command? Something else? It's difficult to help without understanding the context and your overall goal.

--
Owen Wengerd
ManuSoft
Message 3 of 6
Anonymous
in reply to: owenwengerd

[The documentation is correct. You are confusing persistent reactor objects with *references* to persistent reactors (what the documentation refers to as "attachments"), which certainly do get copied.]

 

First,I have a AcDbline in the model-space And I have added a curstomized persistent reactor to it.

sel the line, then Ctrl+C. Ctrl+V in the same drawing.
I test the new-pasted line using follow code to see if the persistent reactor attachment(s) also copied to this new line.

void SelCheckReactors()
{
 ads_name name;
 ads_point pt;
 if(ads_entsel(("sel obj:"),name,pt)==RTNORM){
  AcDbObjectId id;
  acdbGetObjectId(id,name);
  AcDbObjectPointer<AcDbEntity> pEnt(id,AcDb::kForRead);
  if(!pEnt.object()) return;
  AcDbVoidPtrArray* pReactors=pEnt->reactors();
  if (pReactors != NULL && pReactors->length() > 0) {
   for (int i = 0; i < pReactors->length(); i++) {
    void*pSomeSth = pReactors->at(i);
    if (acdbIsPersistentReactor(pSomeSth)) {
     AcDbObjectId persObjId = acdbPersistentReactorObjectId(pSomeSth);
     acutPrintf("\n\nPersistent reactor found.");
     acutPrintf(" Reactor id %lx",persObjId);
    }
   }
  }
 }
}

 But when I test the new-pasted line. not found any persistent reactor!

what's the problem?

Message 4 of 6
owenwengerd
in reply to: Anonymous

Do you see the same result if you use the COPY command? Ctrl-C/Ctrl-V use wblockClone to a new database, so there are any number of conceivable reasons why your reactor wouldn't get cloned to the new database.

 

Assuming the COPY command works as you expect, one technique you can use to narrow down the cause of the wblockClone failure is to strip your reactor down to the bare minimum until the cloning is successful, then start adding things back until it fails.

--
Owen Wengerd
ManuSoft
Message 5 of 6
Anonymous
in reply to: owenwengerd

>>suming the COPY command works as you expect, one technique you can use to narrow down the cause of the >>lockClone failure is to strip your reactor down to the bare minimum until the cloning is successful, then start adding

>>things back until it fails.

 

Thanks for you reply!

I have ttried and "Copy" command works well.I mean by that the presistent reator attchemnt is really "copied".

 

I used AutoCAD2002,But use [Ctrl+C/Ctrl+V] I just add a simple AcDbline with  a presistent reactor attached it.The presistent reactor is really not copied to the new one.

 

As you have side [...to strip your reactor down to the bare minimum until the cloning is successful, then start adding

>>things back until it fails......]

 

your method is good ,but My sample is so simple,a line and a reactor. if only line without the reactor it must be successful and Add the reactor it then failed.

 

May this is by design in AutoCAD .because the [Ctrl+C/Ctrl+V] is wBlockClone or may [Ctrl+V] to a another Database??

I don;t know the exact reason.

 

BTW,If I attach a AcDbObjectReactor to the source line,and in override

 

void JReactor::copied( const AcDbObject* dbObj, const AcDbObject* newObj ){

      GetNumPresreactor(newObj) >0 // if by "copy"

      GetNumPresreactor(newObj) ==0 // if by "Ctrl+C"

}

 

May you can help me.

 

regards.

jzq

Message 6 of 6
artc2
in reply to: Anonymous

When we file out an object, the objectIds of any persistent reactors attached to it are filed out as softPointerIds, so in a wblock, that will NOT cause the persistent reactor objects to be cloned.  This means that unless the persistent reactor objects are being cloned for some other reason (such as if they are entities that are already part of the selection to be wblocked), they will not be cloned and thus they will be lost in the new AcDbDatabase that results from the wblock operation.

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

Post to forums  

Autodesk Design & Make Report

”Boost