[CONNECT C++] Delete a ReportDefinitionNode

I can find a ReportDefinitionNode like this...

ReportDefinitionNodePtr node = ReportDefinitionNode::FindByPath (L"category\definition-name", *activeDgnFile);

How can I delete that node?

Parents
  • You have to use the far-from-intuitive XDataTree APIs. In this case, XDataTreeOwner::DeleteNode().

    I am extremely rusty but something along these lines:

    StatusInt deleteReportDefinition(ReportDefinitionNodeR node)
        {
        auto owner = XDataTreeManager::GetDgnXDataTreeOwner(node.GetDgnFile());
        return nullptr != owner ? owner->DeleteNode(node) : ERROR;
        }

    Note that if any tables have been placed with associations to the report definition, they will not be cleaned up by DeleteNode(). That is not a big deal except that if the user tries to refresh a table's contents from its associated report definition, the refresh will fail. If that's a concern, submit a request to have ReportDefinitionNode::RemoveAllAssociations() moved to the published API.

    Answer Verified By: Jon Summers 

Reply
  • You have to use the far-from-intuitive XDataTree APIs. In this case, XDataTreeOwner::DeleteNode().

    I am extremely rusty but something along these lines:

    StatusInt deleteReportDefinition(ReportDefinitionNodeR node)
        {
        auto owner = XDataTreeManager::GetDgnXDataTreeOwner(node.GetDgnFile());
        return nullptr != owner ? owner->DeleteNode(node) : ERROR;
        }

    Note that if any tables have been placed with associations to the report definition, they will not be cleaned up by DeleteNode(). That is not a big deal except that if the user tries to refresh a table's contents from its associated report definition, the refresh will fail. If that's a concern, submit a request to have ReportDefinitionNode::RemoveAllAssociations() moved to the published API.

    Answer Verified By: Jon Summers 

Children
No Data