ObjextArx初试:选择一条直线
//由于arx本身没有与用户交互的函数,所以在arx中与用户的交互工作都是用ads函数来实现的。ads_name en; ads_point pt; //ads_entsel函数得到实体的名字int rtn = ads_entsel("\n选择实体: ", en, pt); AcDbObjectId eId; if(rtn==RTNORM){ acdbGetObjectId(eId, en); //获取实体id AcDbEntity * pEnt; if(Acad::eOk!=acdbOpenObject(pEnt, eId, AcDb::kForRead)){ return ;//打开实体失败,返回 } if(pEnt->isKindOf(AcDbLine::desc())){ // 判断实体是否是AcDbLine AcDbLine * pLine = (AcDbLine*&)pEnt; ads_printf("\n你选择了一条直线"); ads_printf("\n直线的起点是:%f,%f,%f",pLine->startPoint()); ads_printf("\n直线的终点是:%f,%f,%f",pLine->endPoint()); }// end if else{ ads_printf("\n你选择不是直线"); } pEnt->close(); } acedSSFree(en); //释放选择
?