|
- int FilterObjects(ads采用name ss)
- {
- int resVal;
- char *chLayerName[] = {"0", "Layer1"};
- struct resbuf * resBufLayerFilter = NULL;
- struct resbuf **resBufTemp;
- resBufTemp = &resBufLayerFilter;
- *resBufTemp = acutBuildList(-4, "<OR", 0);
- resBufTemp = &(*resBufTemp)->rbnext;
- for (int nIndex = 0 ; nIndex<2;nIndex++)
- {
- *resBufTemp = acutBuildList (8, chLayerName[nIndex], 0);
- resBufTemp = &(*resBufTemp)->rbnext;
- }
- *resBufTemp = acutBuildList(-4, "OR>", 0);
- resBufTemp = &(*resBufTemp)->rbnext;
- while(true)
- {
- //select all objects only on layer '0, Layer1'
- resVal = acedSSGet(L"采用X", NULL, NULL, resBufLayerFilter, ss);
- if (resVal == RTCAN || resVal == RTERROR)
- {
- //user selected zero objects
- if (resVal == RTERROR)
- acutPrintf (L"\nZero objects are selected.\n");
- acutRelRb(resBufLayerFilter);
- return resVal;
- }
- else
- break;
- }
- acutRelRb(resBufLayerFilter);
- return resVal;
- }
- void ADSKDEX()
- {
- Acad::ErrorStatus es;
- AcGePoint3d pt (0.,0.,0.) ;
- AcGeVector3d ex(1., 0., 0.), ey(0., 1., 0.), ez(0., 0., 1.) ;
- ads采用name SourceSS;
- long sslen = -1;
- AcDbObjectIdArray ObjIDArray;
- ads采用name ename;
- long sscur;
- CString ClasseObj, Result;
- AcDbObjectId eId;
- FilterObjects(SourceSS); //filter the objects based on the layers
- int nRet = acedSSLength(SourceSS, &sslen);
- if (nRet == RTNORM)
- {
- acutPrintf(L"%d objects selected for export\n",sslen);
- }
- if( acedSSLength( SourceSS, &sslen) != RTNORM)
- {
- acutPrintf(L"No Objects are selected for export");
- return;
- }
- for (sscur = 0; sscur < sslen; sscur++)
- {
- acedSSName(SourceSS, sscur, ename);
- acdbGetObjectId(eId, ename);
- ObjIDArray.append(eId);
- }
- AcDbDatabase *pDB = NULL;
- if( ( es = acdbHostApplicationServices()->workingDatabase()->wblock(
- pDB, ObjIDArray, pt ))!=Acad::eOk)
- {
- AfxMessageBox(L"wblock failed", MB采用ICONEXCLAMATION | MB采用OK);
- return;
- }
- es = pDB->dxfOut(L"c:\\test.dxf");
- if(pDB)
- {
- delete pDB; // delete the database.
- pDB = NULL;
- }
- acedSSFree(SourceSS);
- acedSSFree(ename);
- }
复制代码 |
|