- UID
- 270125
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-5-31
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
void initApp();
void unloadApp();
void FirstARX();
void initApp()
{
acedRegCmds->addCommand("FirstARX_Commands","FirstARX","第一次",ACRX_CMD_TRANSPARENT,FirstARX);
}
void unloadApp()
{
acedRegCmds->removeGroup("FirstARX_Commands");
}
void FirstARX()
{
ads_alert("HELLO!按确定你将看到这个文件中的实体(包括多段线,圆弧,直线,等等)所属的类名的一个输出.");
fstream iofile;
iofile.open("g://record.txt",ios::in|ios::out);
AcDbDatabase *pDb=new AcDbDatabase(Adesk::kFalse);
pDb->readDwgFile("g:\\test.dwg");
AcDbBlockTable *pBlkTbl;
pDb->getSymbolTable(pBlkTbl,AcDb::kForRead);
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE,pBlkTblRcd,AcDb::kForRead);
pBlkTbl->close();
AcDbBlockTableRecordIterator *pBlkTblRcdItr;
pBlkTblRcd->newIterator(pBlkTblRcdItr);
AcDbEntity *pEnt;
for(pBlkTblRcdItr->start();!pBlkTblRcdItr->done();pBlkTblRcdItr->step()){
pBlkTblRcdItr->getEntity(pEnt,AcDb::kForRead);
///////////////////////////////////////////////////////////////////////////////////////////
int numPaths,i;
AcDbFullSubentPath subentPath;
int array[4][4],array1[4][4];
int point[3],result[3];
if(!(ads_trans((1,0,0),2,0,1,result)==RTNORM))exit(0);
for(i=0;i<3;i++){
array[0]=result;
}
array[0][3]=0;
if(!(ads_trans((0,1,0),2,0,1,result)==RTNORM))exit(0);
for(i=0;i<3;i++){
array[1]=result;
}
array[1][3]=0;
if(!(ads_trans((0,1,0),2,0,1,result)==RTNORM))exit(0);
for(i=0;i<3;i++){
array[2]=result;
}
array[2][3]=0;
//以上这些代码是为了产生getSubentPathsAtGsMarker()中的ads_point result这个参数
//////////////////////////////////////////////////////////////////////////////
if(!(acedSSNameX(,,)==RTNORM))exit(0);
ads_name ss ;
struct resbuf rbpp;
rbpp.restype=0;rbpp.resval.rstring="ATTDEF";rbpp.rbnext=NULL;
int acedSSNameX (struct resbuf **rbpp, const ads_name ss,
const long i);
int acedSSGet ("X", NULL,
NULL, &rbpp,
ss);
getSubentPathsAtGsMarker(AcDb::kEdgeSubentType,,,array,numPaths,subentPath);
// pEnt->subentPtr(subentPath);这个函数的返回值是指向具体的AcDbCurve的子类型,包括line,circle,arc 等等的指针
acutPrintf("classname:%s\n",(pEnt->isA())->name());
AcGePoint3d *pt;
if((pEnt->isA())->name()=="AcDbLine"){
iofile<<(pEnt->subentPtr(subentPath))->name()<<": startPoint&endPoint";
pt=(pEnt->subentPtr(subentPath))->startPoint();
iofile<<"("<<pt->x<<","<<pt->y<<")";
pt=(pEnt->subentPtr(subentPath))->endPoint();
iofile<<"("<<pt->x<<","<<pt->y<<")"<<endl;
}
else if((pEnt->isA())->name()=="AcDbArc"){
iofile<<(pEnt->isA())->name()<<": center&radius&startAngle&endAngle";
pt=(pEnt->subentPtr(subentPath))->center();
iofile<<"("<<pt->x<<","<<pt->y<<")";
iofile<<(pEnt->subentPtr(subentPath))->radius()<<",";
iofile<<(pEnt->subentPtr(subentPath))->startAngle()<<",";
iofile<<(pEnt->subentPtr(subentPath))->endAngle()<<endl;
}
else if((pEnt->isA())->name()=="AcDbCircle"){
iofile<<(pEnt->isA())->name()<<": center&radius";
pt=(pEnt->subentPtr(subentPath))->center();
iofile<<"("<<pt->x<<","<<pt->y<<")";
iofile<<(pEnt->subentPtr(subentPath))->radius()<<endl;
}
else if((pEnt->isA())->name()=="AcDbPolyline"){
iofile<<(pEnt->isA())->name()<<": AcDbPolyline's vertexes are as follows";
AcDbObjectIterator *pvertexIterator=(pEnt->subentPtr(subentPath))->vertexIterator();
for(pvertexIterator->start();!pvertexIterator->done();pvertexIterator->step()){
(pEnt->subentPtr(subentPath))->openVertex(pt,pvertexIterator->objectId,AcDb::kForRead);
iofile<<"("<<pt->x<<","<<pt->y<<")";
}
iofile<<endl;
delete pvertexIterator;
}
else if((pEnt->isA())->name()=="AcDbSpline"){
int conNum,fitNum,index;
if((pEnt->subentPtr(subentPath))->hasFitData()==Adesk::kTrue){
fitNum=(pEnt->subentPtr(subentPath))->numFitPoints();
iofile<<(pEnt->isA())->name()<<": AcDbSpline's fitPoints are as follows";
for(index=0;index<fitNum;index++){
(pEnt->subentPtr(subentPath))->getFitPointAt(index,pt);
iofile<<"("<<pt->x<<","<<pt->y<<")";
}
}
iofile<<" and ";
iofile<<(pEnt->isA())->name()<<": AcDbSpline's controlPoints are as follows";
for(index=0;index<conNum;index++){
(pEnt->subentPtr(subentPath))->getControlPointAt(index,pt);
iofile<<"("<<pt->x<<","<<pt->y<<")";
}
iofile<<endl;
}
//这里还可以增加对这些实体进行处理的代码。这里只是简单的把这些实体所属的类的名称给输出一下。
iofile.close();
}
pEnt->close();
pBlkTblRcd->close();
delete pBlkTblRcdItr;
delete pDb;
}
extern "C"AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg,void* pkt)
{
switch(msg)
{
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
default:break;
}
return AcRx::kRetOK;
}
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockRec;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockRec, AcDb::kForWrite);
pBlockTable->close();
AcDbBlockTableRecordIterator* pIter;
pBlockRec->newIterator(pIter);
pBlockRec->close();
for (pIter->start(); !pIter->done(); pIter->step())
{
AcDbEntity *pEnt;
if (pIter->getEntity(pEnt, AcDb::kForRead)!= Acad::eOk)
continue;
if(pEnt->isKindOf(AcDbLine::desc()))
{
AcDbLine *p=(AcDbLine *)pEnt;
acutPrintf("\n长度:%.2lf",p->endPoint());
请高手指点。。最好能发我个源码给我看看(tel:13564162766紧急。老师让周4交。。)。。当然指点1、2也是好的 |
|