レイヤーグループの操作例
これは、メカニカルレイヤーとレイヤーグループに関するシリーズの2番目の記事です。シリーズの最初の記事については、パート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
}