使用图层组的示例
这是关于机械图层和图层组系列文章的第二篇。有关该系列的第一篇文章,请参阅第1部分。
要获取所有现有机械图层组名称的数组,请使用以下代码示例:
// Note: The next block of code requires additional inclusion of "AmiLayer.h"
OdDbDatabase* pDb = ... // get a pointer to the current database
OdStringArray layerGroupNames; // array for group names
AmiStatus status = amiGetLayerGroups(layerGroupNames, pDb);
if (status.success())
{
... // Perform an action on the array. For example, display it on the screen.
}
else
{
... // Failure during execution
}
要从特定组获取机械图层名称的数组,请使用以下代码示例:
// Note: The next block of code requires additional inclusion of "AmiLayer.h"
OdDbDatabase* pDb = ... // get a pointer to the current database
OdStringArray layerNames; // array for layer names
OdString groupName = ... // specify the group name
AmiStatus status = amiGetLayersFromGroup(groupName, layerNames, pDb);
if (status.success())
{
... // Perform an action on the array. For example, display it on the screen.
}
else
{
... // Failure during execution
}
要将所有实体从一个组移动到另一个组,请使用以下代码示例:
// Note: The next block of code requires additional inclusion of "AmiLayer.h"
OdDbDatabase* pDb = ... // get a pointer to the current database
OdString srcGroup = ... // specify the source group name
OdString targetGroup = ... // specify the name of the group to which the
// entities will be moved. If no such group exists,
// it will be created if the original group contains
// at least one element
AmiStatus status = amiMoveLayerGroupEntities(srcGroup, targetGroup, pDb);
if (status.success())
{
... // Entities successfully moved
}
else
{
... // Failure during execution or input parameters are incorrect
}
要从特定图层组获取实体ID的数组,请使用以下代码示例:
// Note: The next block of code requires additional inclusion of "AmiLayer.h"
OdDbDatabase* pDb = ... // get a pointer to the current database
// Default mechanical layer group: 'Base Layergroup'
// For getting entity IDs from all layers use '*' as groupName
OdString groupName = ... // specify the layer group name
bool bIgnoreBlocks = ... // set to “true” if blocks should be ignored
bool bOnlyBlockRefs = ... // set to “true” if only block references should be collected
bool bIgnore_FLO_Objects = ... // set to “true” if frozen, locked and off layers should be ignored
OdDbObjectIdArray entityIds; // array for entity IDs
AmiStatus status = amiGetLayerGroupEntities(pDb, groupName, entityIds, bIgnoreBlocks, bOnlyBlockRefs, bIgnore_FLO_Objects);
if (status.success())
{
... // Perform an action on the array. For example iterate through array and display entity names on the screen.
}
else
{
... // Failure during execution or input parameters are incorrect
}