- UID
- 1
- 积分
- 15891
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-10-10 17:53:47
|
显示全部楼层
Re: [求助]:如果一个实体的线型是BYLAYER,如何能得到真的名字?
最初由 LoveArx 发布
[B]如何知道一个实体的线型是否是BYLAYER?如果线型是BYLAYER,如何能得到真的名字?,哪位朋友有现成的代码?急用,谢谢! [/B]
如果实体线型是BYLAYER,那么你就需要打开实体所属层的记录,得到层表记录的线型名。
只要判断实体的线型ID和数据库的BYLAYER ID相等,就能知道实体线型是否是BYLAYER。
给你贴断代码,你可以把下面代码定义一个命令,拾取实体后,如果实体线型是BYLAYER,会打印出层名和真正的线型名。
- [FONT=courier new]
- AcDbEntity *
- selectEntity( const char *prompt, AcDbObjectId& id, AcGePoint3d& pick,
- AcDb::OpenMode openMode )
- {
- AcDbEntity *ent = NULL;
- ads_name ename;
- if ( RTNORM == ads_entsel(prompt, ename, (ads_real*)&pick )){
- if ( Acad::eOk == acdbGetObjectId( id, ename )){
- if ( Acad::eOk == acdbOpenAcDbEntity( ent, id, openMode ))
- return ent;
- }
- }
- return ent;
- }
- // 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();
- }
- [/FONT]
复制代码 |
|