BimRv SDK: Modify Graphics Overrides

Evgeniy Tikhonov

March 09, 2023

This article describes how to retrieve, modify, and remove graphics overrides for elements, categories, and filters defined in a view.

Retrieve Overrides

To retrieve graphics overrides, use the corresponding methods from the OdBmDBView class:

  • Retrieve overrides for elements: getElementOverrides().
  • Retrieve overrides for categories: getCategoryOverrides().
  • Retrieve overrides for filters: getFilterOverrides().
Modify Overrides

To modify graphics overrides, use the following methods from the OdBmDBView class.

To modify overrides for elements, use the setElementOverrides() method. For example:

 OdBmObjectId elemId = pDb->getObjectId(iHandle);

      //Create an empty override and set it as a graphic override for an element
      OdBmOverrideGraphicSettingsPtr pEmptyOverrider = OdBmOverrideGraphicSettings::createObject();
      pActiveView->setElementOverrides(elemId, pEmptyOverrider);

To modify overrides for categories, use the setCategoryOverrides() method. For example:

OdBmElementHeaderPtr pHeader = elemId.getHeader();
      OdInt64 iCategory = static_cast<OdInt64>(pHeader->getCategoryId().getHandle());
      
      OdBm::BuiltInCategory::Enum category = static_cast<OdBm::BuiltInCategory::Enum>(iCategory);
      pActiveView->setCategoryOverrides(category, pEmptyOverrider);

To modify overrides for filters, use the setFilterOverrides() method. The example below shows how to modify an override for a desired filter using its element ID.

OdBmFilterOverridesPtr pFilterOverrides = pActiveView->getFilterOverrides();
      OdBmFilterGraphicSettingsPtrArray aGraphicsSettings;
      pFilterOverrides->getFilterGraphicsSettings(aGraphicsSettings);

      for (auto pSetting : aGraphicsSettings)
      {
        OdBmFilterElementPtr pFilterElem = pSetting->getFilterElemId().safeOpenObject();
        if (pFilterElem->isMatched(elemId))
        {
          pActiveView->setFilterOverrides(pSetting->getFilterElementId(), pEmptyOverrider);
        }
      }

Retrieval methods return an object of the OdBmOverrideGraphicSettings class, and an object of the same class is required for the modification methods. You can use the methods from this class to control the graphics settings.

 

Remove Overrides

To remove all graphics overrides from a view, call the removeAllOverrides() method. Also, setting a newly created OdBmOverrideGraphicSettings object removes the old overrides.

See the full code example in the BmRemoveOverridesCmd command in the BimRv/Examples/TB_Commands directory.