#include "stdafx.h" #include "resource.h" #include "TgAs.h" static const TCHAR *sMsgPrompt[]={ #include "statics.hpp" }; int GridFrame(const TCHAR *pExt); int DbfGridFrame(const TCHAR *pszFile); //extern AcDbObjectId TARCH_IMPEXP GetBlockExtension(const TCHAR *szBlockName); extern BOOL TARCH_IMPEXP StrToIntList(const TCHAR * pszDesc, DList &lstResult); ///////////////////////////////////////// // 把房间实体的数据写到磁盘去 .sp // //UnUsed int SaveSpaceData() { int bDwgTitled=0; xg_getvar(_T("DWGTITLED"), &bDwgTitled); if (!bDwgTitled) { adsout << /*UMSG*/ _T("\n由于当前图尚未命名, 因此房间数据没有保存到磁盘文件!"); return RTERROR; } PickSet ssSpaces(SS_FREE); RBList spaceMask(RTDXF0, _T("ROOM"), NULL); ssSpaces.Get(_T("X"), NULL, NULL, spaceMask); XString sFileSp, sTemplate(256); MakeFullPath(_T(".sp"), sFileSp); //if (!FindFile(sFileSp)) { //sTemplate << g_sAppPath << _T("space.tem"); if (!FindFile(_T("space.tem"), sTemplate)) { adsout << /*UMSG*/ _T("\n找不到文件'") << sTemplate << _T("'"); return RTERROR; } else { if (!CT_cp_file(sTemplate, sFileSp)) { adsout << /*UMSG*/ _T("不能拷贝生成文件'") << sFileSp << _T("'"); return RTERROR; } } //} CodeBase db; XDbfTable *pTable=db.Open(sFileSp); if (!pTable) { adsout << /*UMSG*/ _T("\n不能打开数据库文件'") << sFileSp << _T("'"); return RTERROR; } //////////////////////////////////////////////////// // 并统计楼层数据库中的 usearea, occuarea, ceilarea, extwall, intwall, usevolume, ewinhole, edoorhole double nUseArea=0, nOccuArea=0, nCeilArea=0, nExtWall=0, nIntWall=0, nUseVolume=0, nExtWin=0, nExtDoor=0; long lCount = ssSpaces.Length(); for(long i=0L; iAppendBegin(); SET_FIELD(pTable, _T("code"), pSpace->m_sCode); SET_FIELD(pTable, _T("name"), pSpace->m_sName); SET_FIELD(pTable, _T("height"), pSpace->m_nHeight); SET_FIELD(pTable, _T("usearea"), pSpace->m_nUseArea); SET_FIELD(pTable, _T("ceilarea"), pSpace->m_nCeilArea); SET_FIELD(pTable, _T("occuarea"), pSpace->m_nOccuArea); SET_FIELD(pTable, _T("wallsurf"), pSpace->m_nWallSurfArea); SET_FIELD(pTable, _T("ewallarea"), pSpace->m_nExtWallArea); SET_FIELD(pTable, _T("ewinhole"), pSpace->m_nExtWinArea); SET_FIELD(pTable, _T("edoorhole"), pSpace->m_nExtDoorArea); SET_FIELD(pTable, _T("usevolume"), pSpace->GetUseVolume()); SET_FIELD(pTable, _T("perimeter"), pSpace->m_nPerimeter); SET_FIELD(pTable, _T("kickboard"), pSpace->m_nKickboardLength); pTable->AppendEnd(); if (pSpace->m_sCode==_T("0")) {//ExtSpace nExtWall += pSpace->m_nExtWallArea; } else { nUseArea += pSpace->m_nUseArea; nOccuArea += pSpace->m_nOccuArea; nCeilArea += pSpace->m_nCeilArea; nIntWall += pSpace->m_nWallSurfArea; nUseVolume += pSpace->GetUseVolume(); nExtWin += pSpace->m_nExtWinArea; nExtDoor += pSpace->m_nExtDoorArea; } } /////////////////////////////////////////////////////////////////////// // Static Following: balarea, wallvolume coluvolume holevolume holesurf // Balcony is to be finished // wallvolume, holevolume, holesurf double nWallVolume=0, nHoleVolume=0, nHoleSurf=0; PickSet ssWall(SS_FREE); RBList mask(RTDXF0, _T("TCH_WALL"), NULL); if (ssWall.Get(_T("X"), NULL, NULL, mask)==RTNORM) { long lWallCount=ssWall.Length(); for(long idx=0L; idxGetHoleVolume()); nHoleSurf += _AS_SQMETER(pDbWall->GetHoleSurfaceArea()); nWallVolume += _AS_CUMETER(pDbWall->GetSegVolume()) - _AS_CUMETER(pDbWall->GetHoleVolume()); } } // coluvolume double nColuVolume=0; PickSet ssColu(SS_FREE); RBList maskColu(RTDXF0, _T("TCH_COLUMN"), NULL); if (ssColu.Get(_T("X"), NULL, NULL, maskColu)==RTNORM) { long lCount=ssColu.Length(); for(long idx=0L; idxGetOutline(poly); nColuVolume += _AS_SQMETER(poly.Area())*_AS_METER(pDbColu->GetHeight()); } } GridFrame(_T(".sp")); // Save to Dbf // 取得项目数据库 XString sProjectDbf; if (GetProjectDbf(sProjectDbf)!=RTNORM) { adsout << /*UMSG*/_T("\n不能创建项目数据库, 请把当前图存到一目录(项目)下!"); return RTERROR; } pTable=db.Open(sProjectDbf); XString sCurDwg; AT_GetCurDwg(sCurDwg); _tcsupr(sCurDwg); if (pTable && pTable->MoveTo(_T("dwgfile"), sCurDwg, CMP_INSENSITIVE)) { SET_FIELD(pTable, _T("usearea"), nUseArea); SET_FIELD(pTable, _T("ceilarea"), nCeilArea); SET_FIELD(pTable, _T("occuarea"), nOccuArea); // balcony here, to be finished SET_FIELD(pTable, _T("extwall"), nExtWall); SET_FIELD(pTable, _T("intwall"), nIntWall); SET_FIELD(pTable, _T("usevolume"), nUseVolume); SET_FIELD(pTable, _T("wallvolume"), nWallVolume); SET_FIELD(pTable, _T("coluvolume"), nColuVolume); SET_FIELD(pTable, _T("holevolume"), nHoleVolume); SET_FIELD(pTable, _T("holesurf"), nHoleSurf); SET_FIELD(pTable, _T("ewinhole"), nExtWin); SET_FIELD(pTable, _T("edoorhole"), nExtDoor); } DbfGridFrame(sProjectDbf); return RTNORM; } //extern int SpaceArea(); ///////////////////////////////////////////////////////////////////////// // 统计功能,UnUsed // 1. 建立/更新房间信息 // 2. 更新磁盘上的数据 void Statics() { //if (SpaceArea()==RTNORM) SaveSpaceData(); //return RTNORM; } // extern TARCH_IMPEXP void OpenDwgWithCurNls(CString &csFileName); /////////////////////////////////////////////////////// // 打开dwg文件时自动转换码表 void OpenEx() { XString fileName; xg_getvar(_T("DWGPREFIX"), fileName); //modify by xlc on 090917 2010平台消除tg5lib时去掉了dbf文件打开 #if ADS<18 if (GetFileDia(fileName, 0, _T("dwg;dwt;dxf;dbf"), _T("输入文件名称"))!=RTNORM) #else if (GetFileDia(fileName, 0, _T("dwg;dwt;dxf"), _T("输入文件名称"))!=RTNORM) #endif return; CString csFileName = fileName; // If there is no file extension, try _T(".DWG") if ( csFileName.Find(_T('.')) == -1 ) { csFileName += _T(".DWG"); } else { XPathParser paser(fileName); if (_tcsicmp(paser.m_sExt, _T(".dbf"))==0) { #if ADS<18 DbfGridFrame(csFileName); #endif return; // dwt } } OpenDwgWithCurNls(csFileName); }