AcDbSummaryInfoReactor - how does it work?

AcDbSummaryInfoReactor - how does it work?

Kyudos
Advisor Advisor
557 Views
5 Replies
Message 1 of 6

AcDbSummaryInfoReactor - how does it work?

Kyudos
Advisor
Advisor

I'm attempting to use an AcDbSummaryInfoReactor and I'm having a few problems.

 

As far as I can tell summaryInfoHasChanged is called when the Drawing Properties dialog is OK'd - regardless of whether any changes have been made.

It also seems to be called (unnecessarily?) multiple times - at a guess, once for every Custom Property I have defined.

 

Further, if in my summaryInfoHasChanged  handler I use getCustomSummaryInfo to get the value of the custom property I know I just changed, it only returns the new value on the correct iteration (i.e., if I change the fourth custom property I only get the correct value on the fourth run through the handler otherwise i get the old value).

 

How do you tell which value is currently the one being changed? So I can avoid overwriting it with the old value on subsequent iterations...?

0 Likes
Accepted solutions (1)
558 Views
5 Replies
Replies (5)
Message 2 of 6

Kyudos
Advisor
Advisor

OK - I've discovered that if I use the AcDbDatabaseSummaryInfo pointer from the reactor against the current one from acdbGetSummaryInfo, I can tell when a value changes (get the name and value from the reactor, compare against the value from the current set). However, this involves iterating over the entire set each time the handler is hit.

 

I really hope there is a better way to do this....

0 Likes
Message 3 of 6

owenwengerd
Advisor
Advisor

Did you add the same reactor multiple times?

--
Owen Wengerd
ManuSoft
0 Likes
Message 4 of 6

Kyudos
Advisor
Advisor

Hi Owen,

 

Nope - only once. To be honest, looking at the function definition, I was only expecting it to hit summaryInfoHasChanged once, with a pointer to the whole set of changed (new) data. Finding it hitting the function multiple times, I then thought there must be something that identifies which field is changing each time - but I can't find it?

 

 

0 Likes
Message 5 of 6

Kyudos
Advisor
Advisor

Any advance on this?

 

Is it really meant to work the way it (apparently) does?

0 Likes
Message 6 of 6

Kyudos
Advisor
Advisor
Accepted solution

To answer my own question... I misunderstood the behaviour. It is still strange but slightly easier to deal with. If I wait until the code hits the reactor the final time, it has built a complete set of changed fields.

 

But I need to use a static counter to tell which is the last iteration.

 

//------------------------------------------------------------------------------
void SummaryInfoReactor::summaryInfoHasChanged(const AcDbDatabase* pDb, const AcDbDatabaseSummaryInfo* pSummaryInfo)
//------------------------------------------------------------------------------
{
  m_nIndexCounter++;

  int nInfo = pSummaryInfo->numCustomInfo();
  if (m_nIndexCounter == nInfo)
  {
    m_nIndexCounter = 0;
  }
  else if (m_nIndexCounter == nInfo - 1)
  {
    DocDataManager.docData()->SyncCustomSummaryInfo(pSummaryInfo);
  }
}
0 Likes