...
Hint: The sample application DWG Editor uses this concept.
...
How to select entities by type and layer name?
Status | ||||
---|---|---|---|---|
|
The class CFxUserIO offers a method DoSSGet(...) that allows to pass the selection set to be processed and additionally conditions about what entities are qualified to be selected. The main selection set can be accessed via GetFxMainSelectionSet() from class CFxDocument. The filter is a fdt_resbufW that can be constructed from a builder GetFxAPI()->fdt_buildlistW(). GetFxAPI() can be accessed from CFxDocument. The builder fdt_buildlistW supports to specify a list of parameter. The list of parameter is terminated by a 0.
To specify a filter based on entity type and layer name, the builder should be constructed as follow:
Code Block |
---|
fdt_buildlistW(
RTDXF0, "DXFNAME", // Set DXF-name
8, "LAYERNAME", // Set layer name
0 ); // Termination 0 |
DXF Name | Entity type |
---|---|
LINE | OdDbLine |
CIRCLE | OdDbCircle |
POINT | OdDbPoint |
For more class identifiers you can run the following LISP routine inside ARES Commander. ((-1 . <EName: 00000000551fe260>) (0 . "LINE") (5 . "10B") (330 . <EName: 0000000034f2d000>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbLine") (10 132.6 148.5 0.0) (11 303.0 255.9 0.0) (210 0.0 0.0 1.0)) |
The command context CFxCommandContext is accessible inside the method Execute() from class CFxCommand. We recommend to always use commands but in rare cases the CFxDocument can be also accessed via ACTIVE_DOCUMENT().
Code Block |
---|
// Get main selection
CFxSelectionSet* pFxSelSet = pCmdCtx->GetFxDocument()->GetFxMainSelectionSet();
// Construct resbuf with (dxf code - value) pairs to filter object for selection. Filter works as white-list.
fdt_resbufW *pFilter = pCmdCtx->GetFxDocument()->GetFxAPI()->fdt_buildlistW(
RTDXF0, "CIRCLE", // Set DXF-name
8, "MYLAYER", // Set layer name
0 ); // Termination 0
// Do select with filter.
pCmdCtx->GetFxDocument()->GetFxUserIO()->DoSSGet( CFxUserIO::eFilter, // Set filter mode
pFxSelSet, CFxUserIO::eKwSSGet, L"", L"",
pFilter, // Set filter
0 );
// Release filter
pCmdCtx->GetFxDocument()->GetFxAPI()->fdt_relrbW( pFilter ); |