Custom flyout tools use a package of shapes, rather than a single icon, to represent multiple tools on a flyout palette. In most cases, this means you must create images that you add to an ATC catalog. If your flyout needs only standard AutoCAD commands, however, you can use one of AutoCAD's pre-defined shape catalogs. A flyout tool may use any shape package described in the shapes.atc file.
If you wish to create your own shape catalog, the AcadToolImpl class again facilitates the task. Here is an outline of how to create a new shape catalog and flyout tool.
CComObject<CBoltTool> tool;
AcTcPackage* pShapePackage=tool.CreateShapeCatalogATC("Bolt Flyout Catalog");
if(!tool.CreateToolATC(pShapePackage,"IDB_BOLTALUMINUM")) acutPrintf("\nFailed to create a Tool instance\n");
if(!tool.CreateFlyoutToolATC(pPalette,pShapePackage)) acutPrintf("\nFailed to create a Flyout Tool instance\n");
For the SimpleTool project, you can create a flyout tool more easily by using one of AutoCAD's pre-defined shape packages. You add a function call to create the shape catalog, and another to create the flyout tool. The following example uses the package named “*AutoCADShapes” to create your shape catalog.
AcTcPackage* pPackage = tool.CreateShapeCatalogATC("*AutoCADShapes"); tool.CreateFlyoutToolATC(pPalette, pPackage);
Here is the complete listing of your revised command handler:
static void asdkSimpleToolPalette_CREATESIMPLE(void) { CComObject<CSimpleTool> tool; if (SUCCEEDED(tool.New())) { AcTcCatalog* pCatalog = tool.CreateStockToolATC(_T(“SimpleCatalog”)); AcTcPalette* pPalette = tool.CreatePaletteATC(pCatalog, _T(“SimplePalette”)); AcTcPackage* pPackage = tool.CreateShapeCatalogATC("*AutoCADShapes"); tool.CreateFlyoutToolATC(pPalette, pPackage); tool.CreateCommandToolATC(pPalette, “Line”, “IDB_TOOL1”, “_LINE ”); tool.CreateToolATC(pPalette); AcTcGetManager()->LoadCatalogs(); // Refresh the palette in // AutoCAD } }
For flyout tools, you can display a special property lets users choose which shapes to display. You need to add a new interface property named Flyout, and then add an entry to the flyout property map.
FLYOUT_ENTRY(2)
To see the effect of your flyout property, restart AutoCAD. When the tool palette appears, right-click your flyout tool and choose the Properties menu item. In the General section of the Tool Properties dialog box, you should see a new property named Flyout. In place of a property value, the dialog box displays the Choose Command prompt. Clicking this prompt displays an ellipsis button that launches a Flyout Options dialog box. This dialog box lets the user determine which shapes appear in the flyout menu.
The AcadToolImpl class pre-defines the Flyout property. You can also define your own flyout-specific properties and provide entries for them in the map. These properties apply only to flyout shapes that reference your flyout tool. If shapes within a flyout package reference other tool objects, your properties do not apply to those shapes.