马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
How can I get the real linetype name of any entity (AcDbCurve) when the
linetype() function always return the "ByLayer" string?
Answer
If the linetype for an entity is BYLAYER, go to the layer on which the entity
resides and get the LINETYPELD for that layer. You can then open the linetype
TableRecord to get its name.
NOTE: To determine if the linetype for an entity is set to BYLAYER, get the
object ID of the entity's linetype and compare it to the object ID that is
returned by the current database's byLayerLinetype() method.
This code shows how to do this:
// This is command 'GETLT'
void asdktestergetlt()
{
AcDbObjectId objId;
AcGePoint3d pick;
AcDbEntity *pEnt = selectEntity( "\nSelect entity: ", objId, pick,
AcDb::kForRead );
if ( NULL == pEnt )
return;
if ( pEnt->linetypeId() == pEnt->database()->byLayerLinetype() )
{
AcDbObject *pObj;
if ( Acad::eOk == acdbOpenAcDbObject( pObj, pEnt->layerId(),
AcDb::kForRead ))
{
AcDbLayerTableRecord *pLayer =
AcDbLayerTableRecord::cast( pObj );
if ( NULL != pLayer )
{
AcDbObject *pObj2;
if ( Acad::eOk == acdbOpenAcDbObject( pObj2,
pLayer->linetypeObjectId(), AcDb::kForRead ))
{
AcDbLinetypeTableRecord *pLinetype =
AcDbLinetypeTableRecord::cast( pObj2 );
if ( NULL != pLinetype )
{
char *layerName, *linetypeName;
pLayer->getName( layerName );
pLinetype->getName( linetypeName
);
acutPrintf( "\nEntity lives on
layer %s which uses linetype %s.", layerName, linetypeName );
delete [] layerName;
delete [] linetypeName;
}
pObj2->close();
}
}
pObj->close();
}
}
pEnt->close();
}
|