# Update Child After RemapObjectIds?

**URL:** <https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808>\
**Category:** Rhino Developer\
**Tags:** windows, history, cpp, remapobjectids\
**Created:** [July 13, 2026, 7:00pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808 "2026-07-13T19:00:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ericm/32/478994_2.png) [@EricM](https://discourse.mcneel.com/u/EricM)\
**Post date:** [July 13, 2026, 7:00pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808/1 "2026-07-13T19:00:28Z")

</div>

I’m updating a child obj’s parent.

```auto
  const CRhinoHistoryRecord* record = object->HistoryRecord();
  if (nullptr == record)
    return 0;
  ON_HistoryRecord* copy = doc->m_history_record_table.GetPrunedHistoryRecord(record->RecordIndex());
  if (nullptr == copy)
    return 0;

  ON_SimpleArray<ON_UuidPair> remap(1);
  ON_UuidPair& pair = remap.AppendNew();
  pair.m_uuid[0] = oldParentId;
  pair.m_uuid[1] = newParentId;
  copy->RemapObjectIds(remap);

  CRhinoHistory history(copy); 

  CRhinoHistoryManager* manager = RhinoHistoryManager();
  const bool bRecording = manager->HistoryRecordingEnabled();
  manager->EnableHistoryRecording(true);

  const bool rc = doc->m_history_record_table.CreateObjectHistory(
    const_cast<CRhinoObject*>(object), history);

  manager->EnableHistoryRecording(bRecording);

```

Afterward, how do I get history to replay with the new parent, as you would with `_HistoryUpdate`?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [July 13, 2026, 8:12pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808/2 "2026-07-13T20:12:48Z")

</div>

Hi @EricM,

You cannot update history as a command operation. That is, this is something you cannot trigger mid-command.

That said, you might be able to trigger an update in an idle event handler. In this case, this _might_ work:

```cpp
void HistoryUpdateDescendants(unsigned int docSerialNumber)
{
  CRhinoDoc* pDoc = CRhinoDoc::FromRuntimeSerialNumber(docSerialNumber);
  if (nullptr != pDoc && 0 == pDoc->InCommand(true))
  {
    CRhinoHistoryManager* pHistoryManager = RhinoHistoryManager(pDoc);
    if (pHistoryManager)
      pHistoryManager->UpdateDescendants(*pDoc);
  }
}

```

– Dale

---

<div class="post-metadata">

**Author:** ![EricM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ericm/32/478994_2.png) [@EricM](https://discourse.mcneel.com/u/EricM)\
**Post date:** [July 13, 2026, 9:06pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808/3 "2026-07-13T21:06:29Z")

</div>

Hmm…that’s not ideal. I was able to get it to update by treating it like a normal command. After the remap, I replaced the parent in doc objects with no changes, which triggered a history replay on the child. However, that also broke history on the parent.

What if after I remap the parent, I copy the parent’s history record, replace the parent obj in the doc, and then push that history record back into the table?

---

<div class="post-metadata">

**Author:** ![EricM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ericm/32/478994_2.png) [@EricM](https://discourse.mcneel.com/u/EricM)\
**Post date:** [July 13, 2026, 10:33pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808/4 "2026-07-13T22:33:14Z")

</div>

Oh, what about `UpdateDescendants()`? If you can’t update within a command, where is this meant to be run from?

> **[Rhino C++ API: CRhinoHistoryManager Class Reference](https://mcneel.github.io/rhino-cpp-api-docs/api/cpp/class_c_rhino_history_manager.html#a996e90f2395aa7aaee0507f3a2cd90f3)**
>
> \#include \<rhinoSdkObjectHistory.h\>

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [July 13, 2026, 10:51pm UTC](https://discourse.mcneel.com/t/update-child-after-remapobjectids/220808/5 "2026-07-13T22:51:24Z")

</div>

Hi @EricM,

From rhinoSdkObjectHistory.h:

```cpp
// Expert user tools 
// - no support available 
// - can change without notice
CRhinoCommand::result UpdateDescendants(class CRhinoDoc& doc);

```

I’ve already mentioned how you might use this.

Rhino’s command manager calls this after executing your command.

– Dale
