- UID
- 246950
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-20
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
vc6+atl+wtl+openDWG; 都是些测试代码,编译过,没问题。主要功能是找polyline,并读出其xRecord中的bin Data;
#define _WTL_USE_CSTRING
#define _ATL_USE_CSTRING_FLOAT
#include <atlbase.h>
CComModule _Module;
#include <atlapp.h>
#include <atlmisc.h>
#include <z9/ZCon2.h>
#include <ad2.h>
#include <odio.h>
class ZTest:public IZCon2Impl{
public:
BOOL test1(){
BOOL isOK = FALSE;
AD_DB_HANDLE h;
///初始openDWG;
short err = 0;
if(!adInitAd2("adInit.dat", 0, &err))return FALSE;
adSetupDwgRead();
h = adLoadFile("d:\\ssss.dwg", AD_PRELOAD_ALL, 1);
/////----------------------------
adStartBlockheaderGet(h);
long blockHeaderCount = adNumBlockheaders(h);
AD_TB table;
for(long i=0; i<blockHeaderCount; i++){
adGetBlockheader(h, &table.blkh);
if(table.blkh.purgedflag)continue;
CString recordName = table.blkh.name;
recordName.MakeLower();
if(recordName != "*model_space")continue;
////get entity;
adStartEntityGet(table.blkh.entitylist);
long backNum;
AD_ENT_HDR entHdr;
AD_ENT ent;
long validCount=0;
do{
memset(&entHdr, 0, sizeof(entHdr));
printf("pline type: %i\r\n", adLwplineEnttype(h));
backNum = adGetEntity(table.blkh.entitylist, &entHdr, &ent);
if(backNum){
validCount++;
printf("ent type: %i\r\n", entHdr.enttype);
if(entHdr.enttype == 504 || entHdr.enttype == 503){
////读xrecord;
AD_OBJ_HDR objH;
AD_OBJ obj;
if(adSeekObject(h, entHdr.xdicobjhandle, &objH, &obj)){
printf("get xd oooooo\r\n");
printf("obj type: %i\r\n", objH.objtype);
if(objH.objtype == 32){
AD_DIC* pDic = (AD_DIC*)&obj;
printf("num dic item: %i\r\n", pDic->numdicitems);
if(pDic->numdicitems>0){
AD_BLOB_CTRL* pBlob = adStartBlobRead(pDic->itemblob);
for(long i=0; i<pDic->numdicitems; i++){
AD_DICITEM dicItem;
if(adReadDicItem(pBlob, &dicItem)){
printf("read dic item ooooooo, name: %s\r\n", dicItem.str);
AD_OBJ_HDR objH1;
AD_OBJ obj1;
if(adSeekObject(h, dicItem.itemhandle, &objH1, &obj1)){
if(objH1.objtype == adXrecordObjtype(h)){
printf("dic item is xrecord\r\n");
AD_XRECORD* pX = (AD_XRECORD*)&obj1;
printf("xd databits: %i\r\n", pX->databits);
AD_XD xd;
AD_BLOB_CTRL* pBC = adStartBlobRead(pX->datablob);
while(adReadXrecordItem(pBC, &xd)){
printf("xd.xddxfnumber: %i\r\n", xd.xddxfnumber);
if(xd.xddxfnumber == 310){//kDxfBinaryChunk=310,
printf("data: %s\r\n" ,xd.xddata.xdbindata);
}
}
adEndBlobRead(pBC);
}
}
}
}
adEndBlobRead(pBlob);
}
}
}
AD_LWPLINE* pLine = (AD_LWPLINE*)&ent;
////读点数据;
AD_BLOB_CTRL* pBC = adStartBlobRead(pLine->ldblob);
for(long i=0; i<pLine->numpoints; i++){
double x, y, t;
adReadBlobDouble(pBC, &x);
adReadBlobDouble(pBC, &y);
CString str;
str.Format("x:%0.3f, y:%0.3f\r\n", x, y);
if(pLine->flag & AD_LWPLINE_HAS_BULGES)adReadBlobDouble(pBC, &t);
if(pLine->flag & AD_LWPLINE_HAS_WIDTHS)adReadBlobDouble(pBC, &t);
}
adEndBlobRead(pBC);
////读xrecord;
}
}
////printEnt(entHdr, ent);
}while(backNum == 1 && entHdr.enttype != AD_ENT_ENDBLK);
}
/////============================
///关闭openDWG;
adCloseFile(h);
adCloseAd2();
return isOK;
}
long __stdcall EventNotify_(const char* pName, void* p1, void* p2, void* p3){
if(strcmp(pName, "test1") == 0){
test1();
}
return 0;
}
};
__declspec(dllexport) BOOL __stdcall CreateIZCon2_(const char* pName, IZCon2** ppCon){
if(ppCon){
if(pName == NULL){
IZCon2* pCon = (IZCon2*)(new ZTest());
if(pCon){
*ppCon = pCon;
return TRUE;
}
}else{
}
}
return FALSE;
}
BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved){
if(dwReason == DLL_PROCESS_ATTACH){
_Module.Init(NULL, hInstance, NULL);
}else if(dwReason == DLL_PROCESS_DETACH){
_Module.Term();
}
return TRUE;
} |
|