ODA Drawings Explorer Menu and Toolbar Customization

Yuri Moskovsky

February 16, 2023

ODA Drawings Explorer (ODE) is a QT-based sample application for viewing and editing ODA databases. Support of .dwg files is integrated, and access to databases of other formats (DGN, PRC, etc.) is available through OdDbDatabasePE and the corresponding bridge modules. Editing is supported for DGN and .dwg files. The source code of the application is available in the Drawing/Examples/Qt/OdaQtApp directory.

The application's user interface is based on command processing. Like in Autodesk® AutoCAD®, loading and unloading menus and toolbars is performed using the CUILOAD and CUIUNLOAD commands (the MENU command is a synonym for CUILOAD).

You can also load your CUI files from resources or the file system in the main() function of the application:

int main(int argc, char *argv[])
{
  ...
  QString qsMenuProfile = "qrc:/cui/odq_menu_base.cui",
          qsToolbarsProfile = "qrc:/cui/odq_toolbar_base.cui";
  getIConsole()->postponeCommand(QString("menu \"%1\"").arg(qsMenuProfile), 
                                 true, NULL, 100);
  getIConsole()->postponeCommand(QString("cuiload \"%1\"").arg(qsToolbarsProfile),
                                 true, NULL, 100);
  ...
}

The "qrc:/" prefix is used when loading a CUI file from the resources specified in the Drawing/Examples/Qt/OdaQtApp/data/data.qrc file.

The ODE toolbar and menu files are based on the AutoCAD CUI format for user interfaces. The CUI files were initially created with the Customize User Interface (CUI) Editor of AutoCAD 2009. Since higher versions of AutoCAD use the CUIx format (which is a ZIP-packed directory with a set of CUI files), it's highly recommended to use your preferred text editor instead of the AutoCAD CUI Editor. The file format is based on XML and is quite simple; the number of required changes is usually small.

Just like in AutoCAD, for menu items, icons and commands, preliminary processing is performed through the DIESEL evaluator. For example, if getIConsole()->evaluateDieselExpression(...); for a menu item in the current state of the opened drawing returns text starting with '~', the corresponding menu item is disabled (gray and unclickable). If it's empty text, the menu item is skipped.

The ODE diesel command checks the results in the console, for example:

diesel "$(if,$(or,$(<,$(strlen,$(getvar,filename)),1),$(and,$(eq,$(getvar,tilemode),0),$(eq,$(getvar,cvport),1))),~,)Top"

The command returns "~Top" if there are no open drawings and returns "Top" if there is an open drawing with the Model Space tab selected.

NOTE: While adding a DIESEL command to the CUI file, escape the following XML characters:

 

Original Character

Escaped Character

&

&amp;

"

&quot;

'

&apos;

<

&lt;

>

&gt;

 

ODE uses its own implementation of OdDieselService to call OdDieselEvaluate() — see the OdqDieselServiceImpl class in Drawing/Examples/Qt/OdaQtConsole/OdqConsole.cpp. If necessary, you can extend the set of DIESEL functions by changing the implementation of getSystemVariable() in this class.

To get more information please refer to ODA Documentation.