Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

1537 lines
36 KiB
C++

#include "stdafx.h"
#include "sys/stat.h"
#include "CoreTools.h"
#include "PipelineTools.h"
//#include "EquipManaDlg.h"
#include "EquipmentLibraryDlg.h"
#include "AecDbEwEquipment.h"
#include <io.h>
#include "KTModelLayoutXData.h"
#include "KTCadUtility.h"
#include "KTCadUtilityEx.h"
#include "AecDbEwPipe.h"
#include "./syslayercfg/WSysLayCfgDlg.h"
#include "AddMeritialDlg.h"
#include "EquBand2D.h"
#include "KTSetting.h"
#include "PipeSystemSetting.h"
LPCTSTR PipelineTools::gLayer_Pipe_Dim = _T("LAY_PP3D_DIM");
LPCTSTR PipelineTools::gTextStyle_Pipe_Dim = _T("Pipe_Dim");
namespace
{
bool Band2dForEqu(AecDbEwEquipment *pEqu, LPCTSTR pszFile, const AecDbEwEquipment::ESection &type)
{
if (!pszFile) return false;
if (!pEqu) return false;
if (_taccess(pszFile, 0x00) != 0x00) return false;
CString path(pszFile);
path = path.Right(path.GetLength() - path.ReverseFind(_T('\\')) - 1);
path += _T("-band section's 2D graph.");
// 先根据 path 找一下有没有已经存在的块
// 如果没有,则新建一个
AcDbObjectId idBlk = CoreTools::findTableRecordByPathName(path);
if (!idBlk.isValid())
{
AcGePoint3d ptIns(AcGePoint3d::kOrigin);
if (!PipelineTools::generateBlockRecord(pszFile, _T("*U"), idBlk, ptIns)) return false;
if (!idBlk.isValid()) return false;
OPENOBJ_BEGIN(idBlk, AcDb::kForWrite, AcDbBlockTableRecord, pR)
if (pR) pR->setPathName(path);
OPENOBJ_END()
}
pEqu->setSectionID(type, idBlk);
return true;
}
int ScrSize(ads_real *width, ads_real *height)
{
struct resbuf screensize, viewsize;
ads_getvar(_T("SCREENSIZE"), &screensize);
ads_getvar(_T("VIEWSIZE"), &viewsize);
*height = viewsize.resval.rreal;
*width = screensize.resval.rpoint[X] / screensize.resval.rpoint[Y] * (*height);
return RTNORM;
}
void InitView(AcDbViewTableRecord &view)
{
struct resbuf rb0, rb1, rb2;
rb0.restype = RTSHORT;
rb0.resval.rint = 0;
rb0.rbnext = NULL;
rb1.restype = RTSHORT;
rb1.resval.rint = 1;
rb1.rbnext = NULL;
rb2.restype = RTSHORT;
rb2.resval.rint = 2;
rb2.rbnext = NULL;
struct resbuf rb;
acedGetVar(_T("VIEWMODE"), &rb);
int viewmode = rb.resval.rint;
ads_point ptViewCtr;
acedGetVar(_T("VIEWCTR"), &rb);
ads_point_set(rb.resval.rpoint, ptViewCtr);
ads_point ptDcs;
acedTrans(ptViewCtr, &rb1, &rb2, 0, ptDcs);
acedGetVar(_T("CVPORT"), &rb);
int nCurVp = rb.resval.rint;
view.setIsPaperspaceView(nCurVp == 1);
view.setCenterPoint(asPnt2d(ptDcs));
double nWidth, nHeight;
ScrSize(&nWidth, &nHeight);
view.setHeight(nHeight);
view.setWidth(nWidth);
ads_point vtViewDir;
acedGetVar(_T("VIEWDIR"), &rb);
ads_point_set(rb.resval.rpoint, vtViewDir);
acedTrans(vtViewDir, &rb1, &rb2, 1, vtViewDir);
view.setViewDirection(asPnt3d(vtViewDir).asVector());
acedGetVar(_T("VIEWTWIST"), &rb);
double viewtwist = rb.resval.rreal;
view.setViewTwist(viewtwist);
ads_point target;
acedGetVar(_T("TARGET"), &rb);
ads_point_set(rb.resval.rpoint, target);
acedTrans(target, &rb1, &rb0, 0, target);
view.setTarget(asPnt3d(target));
if (viewmode & 0x01)
{
view.setPerspectiveEnabled(true);
if (viewmode & 0x04)
{
acedGetVar(_T("BACKZ"), &rb);
double backz = rb.resval.rreal;
view.setBackClipEnabled(true);
view.setBackClipDistance(backz);
}
if (viewmode & 0x02)
{
view.setFrontClipEnabled(true);
if (viewmode & 0x10)
{
view.setFrontClipAtEye(false);
acedGetVar(_T("FRONTZ"), &rb);
double frontz = rb.resval.rreal;
view.setFrontClipDistance(frontz);
}
else
{
view.setFrontClipAtEye(true);
}
}
acedGetVar(_T("LENSLENGTH"), &rb);
double lenslength = rb.resval.rreal;
view.setLensLength(lenslength);
}
}
int ParaseString(LPCTSTR pszText, CStringArray& arFields, TCHAR ch)
{
CString sTemp, sText;
sText = pszText;
for (int i = 0; i < sText.GetLength(); i++)
{
if (sText.GetAt(i) == ch)
{
arFields.Add(sTemp);
sTemp = _T("");
}
else
{
sTemp += sText.GetAt(i);
if (i == sText.GetLength() - 1)
{
arFields.Add(sTemp);
}
}
}
return arFields.GetSize();
}
int GetSystemDimkeyByLayer(CUIISQLiteServer *pDb, LPCTSTR pszLayer, CString& sTemp)
{
if (pDb == NULL)
return FALSE;
CString sSQL;
//sSQL = _T("select tablename from wpipecfg");
//CStringArray arVals;
//pDb->GetSelData(sSQL, arVals);
CString sTable(CoreTools::getCurrentPipeSysTblName()), sSys;
//for (int i = 0; i < arVals.GetSize(); i++)
if (!sTable.IsEmpty())
{
// sTable = arVals.GetAt(i);
sSQL.Format(_T("select dimkey from [%s] where layname='%s'"), sTable, pszLayer);
if (pDb->GetSelData(sSQL, sTemp))
{
return TRUE;
}
}
return FALSE;
}
void getSSExtend(ads_name ss, AcDbExtents &ext)
{
Adesk::Int32 len(0);
AcDbObjectId id(AcDbObjectId::kNull);
acedSSLength(ss, &len);
AcDbExtents e;
for (long i = 0; i < len; ++i)
{
ads_name ent;
acedSSName(ss, i, ent);
acdbGetObjectId(id, ent);
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
{
if (pEnt)
{
pEnt->getGeomExtents(e);
ext.addExt(e);
}
}
OPENOBJ_END()
}
}
}
bool PipelineTools::GetEquipmentFile(CString &filePath)
{
CAcModuleResourceOverride myResources;
int idx = CEquipmentLibraryDlg::selectSingleEquID();
if (idx == -1) return false;
filePath = FilePath::getSystemTemporaryFolder() + _T("\\equ.tmp");
if (_taccess(filePath, 0x00) == 0x00)
::DeleteFile(filePath);
return GetEquipmentFile(idx, filePath);
}
bool PipelineTools::GetEquipmentFile(const int & idx, CString &equFile)
{
//解包到临时文件
CString sSQL(_T(""));
equFile = FilePath::getSystemTemporaryFolder() + _T("\\temp$$.equ");
sSQL.Format(_T("select package from aec_package where ID=%d"), idx);
CUIISQLiteServer sqlDb;
CString dbPath = FilePath::GetSysDir();
dbPath += _T("\\Aec3DMep.db");
if (_taccess(dbPath, 0x00) != 0x00)
{
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
return false;
}
if (!sqlDb.InitADOServer(dbPath)) return false;
if (!sqlDb.GetSelBlob(sSQL, equFile)) return false;
return true;
}
bool PipelineTools::GetEquipmentFile(int & idx)
{
CAcModuleResourceOverride myResources;
idx = CEquipmentLibraryDlg::selectSingleEquID();
if (idx == -1) return false;
return true;
}
AcDbObjectId PipelineTools::AecInitLayerEx(LPCTSTR pszLayer, int nColorIndex, LPCTSTR pszLineType, AcDbDatabase* pDb = NULL)
{
CString sLayerInit = pszLayer;
CString sLineTypeinit = pszLineType;
int nLineWidth = AcDb::kLnWt000;
if (pDb == NULL)
pDb = acdbCurDwg();
//映射到系统图层
CString dbPath = FilePath::GetSysDir();
dbPath += _T("\\Plumbing.db");
CUIISQLiteServer *pDbSrv = new CUIISQLiteServer;
pDbSrv->InitADOServer(dbPath);
if (pDbSrv)
{
CString sSQL, sTablename(CoreTools::getCurrentPipeSysTblName()), sCurrSys;
sCurrSys = getCurrentLayerSys();
//sSQL = _T("select tablename from wpipecfg where currstd=1");
//if (pDbSrv->GetSelData(sSQL, sTablename))
if (!sTablename.IsEmpty())
{
//LAYKEY LAYNAME PIPESYS SYSTEM COLOR LINETYPE LINEWIDTH
//11 废水管线中心线 管线中心线 废水 4 Continuous:________ 0
sSQL.Format(_T("select layname,pipesys,color,linetype,linewidth from [%s] where system='%s'"), sTablename, sCurrSys);
CUIIValueTable table;
pDbSrv->GetSelData(sSQL, table);
DELETE_PTR(pDbSrv);
CStringArray arVals;
CString sLayName, sPipeSys, sColor, sLineType, sLineWidth, sTemp;
for (int i = 0; i < table.GetTableLogicSize(); i++)
{
arVals.RemoveAll();
table.GetValueRecord(i, arVals);
sLayName = arVals.GetAt(0);
sPipeSys = arVals.GetAt(1);
sColor = arVals.GetAt(2);
sLineType = arVals.GetAt(3);
//管线中心线
if (_tcscmp(pszLayer, LAY_PIPE_CENTER) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
//管线边线
if (_tcscmp(pszLayer, LAY_PIPE_OUTSIDE) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
//管线中心线 单线
if (_tcscmp(pszLayer, PIPE_SINGLE_SYS) == 0)
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
//FITN_CENTER_SYS
if (_tcscmp(pszLayer, LAY_FITN_CENTER) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
if (_tcscmp(pszLayer, LAY_FITN_OUTSIDE) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
if (_tcscmp(pszLayer, LAY_FITN_SINGLE) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
if (_tcscmp(pszLayer, LAY_EQU) == 0 )
{
sLayerInit = sLayName;
sLineTypeinit = sLineType;
nColorIndex = _ttoi(sColor);
nLineWidth = _ttoi(sLineWidth);
break;
}
}
}
}
AcDbObjectId id;
AcDbLayerTable* pLayTbl = NULL;
if (Acad::eOk == pDb->getLayerTable(pLayTbl, AcDb::kForWrite))
{
if (Acad::eOk == pLayTbl->getAt(sLayerInit, id))
{
//如果找到
pLayTbl->close();
return id;
}
AcCmColor color;
color.setColorIndex(nColorIndex);
AcDbLayerTableRecord* pRec = new AcDbLayerTableRecord;
pRec->setColor(color);
pRec->setLineWeight((AcDb::LineWeight)nLineWidth);
//首先判断是否有此线型
bool bFind = false;
AcDbObjectId idLt;
AcDbLinetypeTable* pLTbl = NULL;
if (Acad::eOk == pDb->getLinetypeTable(pLTbl, AcDb::kForRead))
{
if (Acad::eOk == pLTbl->getAt(sLineTypeinit, idLt))
{
bFind = true;
}
pLTbl->close();
}
if (!bFind)
{
//加载线型
//D:\Program Files\AutoCAD 2008\acad.exe
TCHAR szFileName[MAX_PATH];
::GetModuleFileName(acedGetAcadWinApp()->m_hInstance, szFileName, MAX_PATH);
//
CString sLtFile = szFileName;
sLtFile.MakeLower();
#ifndef ZWCAD
sLtFile.Replace(_T("acad.exe"), _T("support\\acad.lin"));
#else
sLtFile.Replace(_T("zwcad.exe"), _T("support\\acad.lin"));
#endif // !ZWCAD
CFileFind find;
if (find.FindFile(sLtFile))
{
acdbLoadLineTypeFile(sLineTypeinit, sLtFile, pDb);
if (Acad::eOk == pDb->getLinetypeTable(pLTbl, AcDb::kForRead))
{
pLTbl->getAt(sLineTypeinit, idLt);
pLTbl->close();
}
}
else
{
if (CoreTools::FindFile(_T("acad.lin"), sLtFile))
{
acdbLoadLineTypeFile(sLineTypeinit, sLtFile, pDb);
if (Acad::eOk == pDb->getLinetypeTable(pLTbl, AcDb::kForRead))
{
pLTbl->getAt(sLineTypeinit, idLt);
pLTbl->close();
}
}
}
}
pRec->setName(sLayerInit);
pRec->setLinetypeObjectId(idLt);
pLayTbl->add(id, pRec);
pRec->close();
pLayTbl->close();
}
return id;
}
bool PipelineTools::getSqliteDB(LPCTSTR dbName, CUIISQLiteServer & db)
{
CString dbPath = FilePath::GetSysDir();
dbPath += _T("\\");
dbPath += dbName;
if (!db.InitADOServer(dbPath))
return false;
return true;
}
Acad::ErrorStatus PipelineTools::arxZoomTo(const ads_point ptCen, double nWidth, double nHeight)
{
AcDbViewTableRecord view;
InitView(view);
struct resbuf rb0, rb2;
rb0.restype = RTSHORT;
rb0.resval.rint = 0;
rb0.rbnext = NULL;
rb2.restype = RTSHORT;
rb2.resval.rint = 2;
rb2.rbnext = NULL;
ads_point ptDcs;
acedTrans(ptCen, &rb0, &rb2, 0, ptDcs);
view.setCenterPoint(asPnt2d(ptDcs));
view.setHeight(nHeight);
view.setWidth(nWidth);
return acedSetCurrentView(&view, NULL);
}
double PipelineTools::getPScale()
{
double dPScale(100.);
CString sScale(_T("1:100"));
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_SCALE, sScale);
int idx = sScale.Find(':');
if (idx != -1)
{
sScale = sScale.Right(sScale.GetLength() - idx - 1);
dPScale = _ttof(sScale);
}
return dPScale;
}
void PipelineTools::getDimTxtHeight_PIPE(double &h, double &w)
{
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_DIMTXTH, h);
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_DIMTXTF, w);
}
void PipelineTools::getDimTxtHeight_EQU(double &h, double &w)
{
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_EQPTXTH, h);
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_EQPTXTF, w);
}
void PipelineTools::getDimTxtHeight_STR(double &h, double &w)
{
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_STRTXTH, h);
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(DOC_STRTXTF, w);
}
CString PipelineTools::getCurrentLayerSys()
{
CString sysName(_T(""));
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
xDataMap.GetAt(_T("PIPE_LAY_SYS"), sysName);
return sysName;
}
void PipelineTools::setCurrentLayerSys(LPCTSTR sys)
{
AecDbObjXDataMap xDataMap;
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
{
xDataMap.SetAt(_T("PIPE_LAY_SYS"), sys);
KTModelLayoutXData::WriteModelXData(KT_PIPEINIT, xDataMap);
}
}
int PipelineTools::FormatDimText(CUIISQLiteServer *pDb
, AecDbObjXDataMap& xDimMap
, AecDbObjXDataMap* pPipeXData
, CString& sDimUp
, CString& sDimDwn
, double dEl
, TCHAR* pszLayer
, int nUnit//单位
, bool bDimHorPipeEl/* = true*/)
{
if (pPipeXData == NULL)
{
if (pszLayer == NULL)
acutDelString(pszLayer);
return 0;
}
//{0}{-}{1}{-}{2}{-}{3} -> {公称直径}{-}{介质}{-}{管道等级}
CString sDimupScr;
xDimMap.GetAt(DOC_SCRIPTT, sDimupScr);
CString sDimdwScr;
xDimMap.GetAt(DOC_SCRIPTB, sDimdwScr);
/*const LPCTSTR g_pszPipeDim[] =
{ _T("公称直径"), //0
_T("介质"), //1
_T("管号"), //2
_T("压力等级"), //3
_T("外径x 壁厚"),//4
_T("标高"), //5
_T("类型"), //6
_T("保温伴热"), //7
_T("弯头比率"), //8
_T("标准"), //9
_T("材质"), //10
_T("区号"), //11
_T("系统"), //12
NULL
};*/
BOOL bDN = FALSE, bD = FALSE, bAD = FALSE;
xDimMap.GetAt(DOC_DNPRE, bDN);
xDimMap.GetAt(DOC_DPRE, bD);
xDimMap.GetAt(DOC_ADPRE, bAD);
//DN
CString sDn;
double dDn = 0.0;
pPipeXData->GetAt(PIPE_DN, dDn);
if (bAD)
{
sDn.Format(_T("%%%%c%d"), (int)dDn);
}
else
{
if (bDN)
sDn.Format(_T("DN%d"), (int)dDn);
else
sDn.Format(_T("%d"), (int)dDn);
}
sDimupScr.Replace(_T("{0}"), sDn); //
sDimdwScr.Replace(_T("{0}"), sDn); //
//Med
CString sMedia = _T("");
pPipeXData->GetAt(PIPE_MEDIA, sMedia);
sDimupScr.Replace(_T("{1}"), sMedia); //
sDimdwScr.Replace(_T("{1}"), sMedia); //
//PIPENO
CString sPipeno;
pPipeXData->GetAt(PIPE_NO, sPipeno);
sDimupScr.Replace(_T("{2}"), sPipeno); //
sDimdwScr.Replace(_T("{2}"), sPipeno); //
//Press lev
CString sLevel;
pPipeXData->GetAt(PIPE_LEVEL, sLevel);
sDimupScr.Replace(_T("{3}"), sLevel); //
sDimdwScr.Replace(_T("{3}"), sLevel); //
//外径x 壁厚
CString sTemp;
double dOd = dDn;
double dTh = 0.0;
pPipeXData->GetAt(PIPE_OD, dOd);
pPipeXData->GetAt(PIPE_THICK, dTh);
if (bAD)
{
sTemp.Format(_T("%%%%c%dx%.1f"), (int)dOd, dTh);
}
else
{
if (bD)
sTemp.Format(_T("D%dx%.1f"), (int)dOd, dTh);
else
sTemp.Format(_T("%dx%.1f"), (int)dOd, dTh);
}
sDimupScr.Replace(_T("{4}"), sTemp); //
sDimdwScr.Replace(_T("{4}"), sTemp); //
//El
//double dEl = 0.0;
//pPipeXData->GetAt(PIPE_EL,dEl);
CString sElDescr;
int nVal = 0;
xDimMap.GetAt(DOC_ELTYPE, nVal);
xDimMap.GetAt(DOC_ELDESCR, sElDescr);
CStringArray arELs;
ParaseString(sElDescr, arELs, KT_SEPARATOR_CHAR);
sTemp = _T("");
//标高一律居中为准
bool bEleMeter = CoreTools::IsMeterUnitForPipeElevDim();
int nElePrec = CoreTools::getPrecForPipeElevDim();
CString sEl = _T(""), sPrec = _T("");
if (bDimHorPipeEl)
{
sPrec.Format(_T("%%.%df%s"), nElePrec, bEleMeter ? _T("m") : _T("mm"));
sEl.Format(sPrec, bEleMeter ? dEl * .001 : dEl);
switch (nVal)
{
case 0://符号标高
{
sTemp.Format(_T("%s%s"), DIM_CEN_EL, sEl);
break;
}
case 1://简写标高
{
sTemp.Format(_T("%s%s"), PIPE_CEN_EL, sEl);
break;
}
case 2://自定义标高
{
sTemp.Format(_T("%s%s"), arELs.GetAt(2), sEl);
break;
}
default:
break;
}
}
sDimupScr.Replace(_T("{5}"), sTemp); //
sDimdwScr.Replace(_T("{5}"), sTemp); //
//类型, 即系统
//获取分系统类型
sTemp = _T("");
GetSystemDimkeyByLayer(pDb, pszLayer, sTemp);
sDimupScr.Replace(_T("{6}"), sTemp); //
sDimdwScr.Replace(_T("{6}"), sTemp); //
sTemp = _T("");
pPipeXData->GetAt(DOC_INSTRATAG, nVal);
if (nVal == 0)
{
sTemp = _T("无保温伴热");
}
else if (nVal == 1)
{
sTemp = _T("保温");
}
else if (nVal == 2)
{
sTemp = _T("保温加伴热");
}
sDimupScr.Replace(_T("{7}"), sTemp); //
sDimdwScr.Replace(_T("{7}"), sTemp); //
//弯头比率
sTemp = _T("");
double dRat = 1.0;
pPipeXData->GetAt(PIPE_RATIO, dRat);
sTemp.Format(_T("%.1f"), dRat);
sDimupScr.Replace(_T("{8}"), sTemp); //
sDimdwScr.Replace(_T("{8}"), sTemp); //
//标准,无
sTemp = _T("");
sDimupScr.Replace(_T("{9}"), sTemp); //
sDimdwScr.Replace(_T("{9}"), sTemp); //
//材质
sTemp = _T("");
pPipeXData->GetAt(PIPE_MATERIAL, sTemp);
//如果不是官子,按ft材质
nVal = 0;
pPipeXData->GetAt(KEY_RUNTIME, nVal);
if (nVal != ePipe)
{
pPipeXData->GetAt(PIPE_MATERIALFT, sTemp);
}
sDimupScr.Replace(_T("{10}"), sTemp); //
sDimdwScr.Replace(_T("{10}"), sTemp); //
//区号
sTemp = _T("");
pPipeXData->GetAt(PIPE_ZONE, sTemp);
sDimupScr.Replace(_T("{11}"), sTemp); //
sDimdwScr.Replace(_T("{11}"), sTemp); //
//系统
pPipeXData->GetAt(PIPE_SYS, sTemp);
sTemp.Replace(_T("管"),_T(""));
sTemp += _T("管");//系统加上管
sDimupScr.Replace(_T("{12}"), sTemp); //
sDimdwScr.Replace(_T("{12}"), sTemp); //
//单元号
sTemp = _T("");
pPipeXData->GetAt(PIPE_UNITNO, sTemp);
sDimupScr.Replace(_T("{13}"), sTemp); //
sDimdwScr.Replace(_T("{13}"), sTemp); //
sDimUp = sDimupScr;
sDimDwn = sDimdwScr;
sDimUp.TrimRight(_T('_'));
sDimDwn.TrimRight(_T('_'));
sDimUp.TrimLeft(_T('_'));
sDimDwn.TrimLeft(_T('_'));
sDimUp.TrimRight(_T('-'));
sDimDwn.TrimRight(_T('-'));
sDimUp.TrimLeft(_T('-'));
sDimDwn.TrimLeft(_T('-'));
sDimUp.Replace(_T("{"), _T(""));
sDimDwn.Replace(_T("{"), _T(""));
sDimUp.Replace(_T("}"), _T(""));
sDimDwn.Replace(_T("}"), _T(""));
//再次确认剪除-
sDimUp.TrimRight(_T('_'));
sDimDwn.TrimRight(_T('_'));
sDimUp.TrimLeft(_T('_'));
sDimDwn.TrimLeft(_T('_'));
sDimUp.TrimRight(_T('-'));
sDimDwn.TrimRight(_T('-'));
sDimUp.TrimLeft(_T('-'));
sDimDwn.TrimLeft(_T('-'));
return TRUE;
}
int PipelineTools::GetSamplePoints(AcDbCurve* pCrv, AcGePoint3dArray& arPoints)
{
double dSta = 0.0, dEnd = 0.0;
pCrv->getStartParam(dSta);
pCrv->getEndParam(dEnd);
double dStep = (dEnd - dSta) / 16.0;
AcGePoint3d ptGeT;
for (int i = 0; i < 16; i++)
{
pCrv->getPointAtParam(dSta + i * dStep, ptGeT);
arPoints.append(ptGeT);
}
arPoints.append(arPoints.first());
return arPoints.length();
}
BOOL PipelineTools::arxWBlock(ads_name ss, const TCHAR * szFileName, AcGePoint3d ptIns)
{
//ads_point adsPtWCS;
//acdbUcs2Wcs(asDblArray(ptIns), adsPtWCS, false);
//ptIns = asPnt3d(adsPtWCS);
AcDbObjectIdArray cloneSet;
Adesk::Int32 len(0);
acedSSLength(ss, &len);
AcDbExtents ext, extAll;
for (long i = 0; i < len; i++)
{
ads_name ent;
acedSSName(ss, i, ent);
AcDbObjectId id;
acdbGetObjectId(id, ent);
cloneSet.append(id);
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
{
if (pEnt)
{
pEnt->getGeomExtents(ext);
extAll.addExt(ext);
}
}
OPENOBJ_END()
}
AcDbDatabase db;
AcDbObjectId idMSpace = db.currentSpaceId();
AcDbIdMapping idMap;
acdbCurDwg()->wblockCloneObjects(cloneSet, idMSpace, idMap, AcDb::kDrcIgnore, false);
AcDbBlockTable *pTable = NULL;
db.getBlockTable(pTable, AcDb::kForRead);
if (!pTable)
{
return FALSE;
}
AcGeMatrix3d mat;
mat.setToTranslation(AcGeVector3d(-ptIns.x, -ptIns.y, -ptIns.z));
AcDbBlockTableRecord *pBlockTableRecord = NULL;
VERIFY(pTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead) == Acad::eOk);
pTable->close();
if (!pBlockTableRecord)
{
return FALSE;
}
AcDbBlockTableRecordIterator* pBlockIterator = NULL;
pBlockTableRecord->newIterator(pBlockIterator);
if (!pBlockIterator)
{
pBlockTableRecord->close();
return FALSE;
}
for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step())
{
AcDbEntity *pEnt = NULL;
pBlockIterator->getEntity(pEnt, AcDb::kForWrite);
if (pEnt)
{
pEnt->transformBy(mat);
pEnt->close();
}
}
delete pBlockIterator;
pBlockTableRecord->close();
AcGePoint3d ptMax(extAll.maxPoint()), ptMin(extAll.minPoint());
db.setExtmax(ptMax);
db.setExtmin(ptMin);
db.setInsbase(ptIns);
return (acdbSaveAs2000(&db, szFileName) == Acad::eOk);
}
bool PipelineTools::makeBlockToDWG(CString &path)
{
ads_name ss;
struct resbuf* pRb = acutBuildList(RTDXF0, _T("*"), 0);
if (CKTCadUtility::SelectEntities(_T("请选择对象:"), ss, pRb) != RTNORM)
{
acutRelRb(pRb);
return false;
}
acutRelRb(pRb);
AcDbExtents ext;
getSSExtend(ss, ext);
AcGePoint3d ptCen(AcGePoint3d::kOrigin);
Midpoint(ext.minPoint(), ext.maxPoint(), ptCen);
ptCen.z = 0;
acutPrintf(_T("\n选择图块基点<%4f,%4f>:"), ptCen.x, ptCen.y);
ads_point adsptCen, basePt;
acdbWcs2Ucs(asDblArray(ptCen), adsptCen, false);
if (ads_getpoint(adsptCen, _T(""), basePt) != RTNORM)
{
acedSSFree(ss);
return false;
}
// 不再转成UCS了
CString tmpPath(FilePath::getSystemTemporaryFolder() + _T("\\temp_$_dwg_$_.dwg"));
if (_taccess(tmpPath, 0x0) == 0x0)
{ // 如果存在,删除,无法删除则返回
if (!::DeleteFile(tmpPath)) return false;
}
if (arxWBlock(ss, tmpPath, asPnt3d(basePt)))
{
path = tmpPath;
acedSSFree(ss);
return true;
}
acedSSFree(ss);
return false;
}
bool PipelineTools::generateBlockRecord(LPCTSTR pszDwg, LPCTSTR pszBlkName, AcDbObjectId & id, AcGePoint3d &ptIns)
{
if (!pszDwg || !pszBlkName) return false;
AcDbDatabase* pDb = new AcDbDatabase(false);
#if ARX >= 21
if (pDb->readDwgFile(pszDwg, AcDbDatabase::kForReadAndAllShare) != Acad::eOk)
#else
if (pDb->readDwgFile(pszDwg, _SH_DENYNO) != Acad::eOk)
#endif
{
delete pDb;
return false;
}
ptIns = pDb->insbase();
AcDbBlockTable* pBT = NULL;
pDb->getSymbolTable(pBT, AcDb::kForRead);
if (pBT == NULL)
{
delete pDb;
return false;
}
AcDbObjectId idBlock;
pBT->getAt(ACDB_MODEL_SPACE, idBlock);
pBT->close();
AcDbDatabase* pTempDb = NULL;
pDb->wblock(pTempDb, idBlock);
delete pDb;
if (pTempDb == NULL) return false;
AcDbDatabase* pWorkDb = acdbHostApplicationServices()->workingDatabase();
if (pWorkDb->insert(id, pszBlkName, pTempDb) != Acad::eOk)
{
delete pTempDb;
return false;
}
delete pTempDb;
return true;
}
AcDbObjectId PipelineTools::makeLayer(LPCTSTR layname, AcDbDatabase *pDb)
{
if (!layname) return AcDbObjectId::kNull;
AcDbObjectId idLay = CoreTools::findLayerId(layname, pDb);
if (idLay.isValid()) return idLay;
if (!pDb) pDb = acdbCurDwg();
AcDbLayerTable *pLayerTable(NULL);
if (pDb->getLayerTable(pLayerTable, AcDb::kForWrite) != Acad::eOk) return idLay;
AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord;
pLayerTableRecord->setName(layname);
pLayerTable->add(idLay, pLayerTableRecord);
pLayerTableRecord->close();
pLayerTable->close();
return idLay;
}
AcDbObjectId PipelineTools::initLineType(LPCTSTR linetype, AcDbDatabase * pDb, LPCTSTR linfile)
{
if (!linetype) return AcDbObjectId::kNull;
CString lin(_T("acad.lin"));
if (linfile) lin = linfile;
if (!pDb) pDb = acdbCurDwg();
AcDbObjectId idLineType = CoreTools::findLinetypeId(linetype, pDb);
if (!idLineType)
{
pDb->loadLineTypeFile(linetype, lin);
idLineType = CoreTools::findLinetypeId(linetype, pDb);
}
return idLineType;
}
AcDbObjectId PipelineTools::initShLineType(LPCTSTR linetype, LPCTSTR pszDimkey,AcDbDatabase * pDb, LPCTSTR linfile)
{
if (!linetype) return AcDbObjectId::kNull;
CString lin(_T("sh.lin"));
if (linfile) lin = linfile;
if (!pDb) pDb = acdbCurDwg();
CString sLt = linetype;
sLt.Replace(_T("GAS"),pszDimkey);
AcDbObjectId idLineType = CoreTools::findLinetypeId(sLt, pDb);
if (!idLineType)
{
CString sPath = FilePath::GetSysDir();
CString sShFile = sPath;
sShFile += _T("\\sh.lin");
CString sLin1 = _T("*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--");
CString sLine2 = _T("A,.75,-.2,[\"GAS\",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25");
sLin1.Replace(_T("GAS"),pszDimkey);
sLine2.Replace(_T("GAS"),pszDimkey);
CStdioFile file;
if (file.Open(sShFile,CFile::modeCreate|CFile::modeWrite))
{
file.SeekToEnd();
file.WriteString(sLin1);
file.WriteString(_T("\n"));
file.WriteString(sLine2);
file.WriteString(_T("\n"));
file.Close();
}
pDb->loadLineTypeFile(sLt, _T("sh.lin"));
idLineType = CoreTools::findLinetypeId(sLt, pDb);
}
return idLineType;
}
bool PipelineTools::isDoubleLine(const double & dW)
{
AecDbObjXDataMap xDataMap;
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap);
double d(0);
if (xDataMap.GetAt(DOC_PIPEMAXDIA, d))
if (dW >= d) return true;
return false;
}
bool PipelineTools::getPipelineParam(AecDbObjXDataMap & xmap, CString & layer)
{
ads_name ss, ent;
struct resbuf rb;
TCHAR szBuf[64];
rb.restype = 0;
_tcscpy(szBuf, _T("AEC_EWPIPE"));
rb.resval.rstring = szBuf;
rb.rbnext = NULL;
int nRes = acedSSGet(NULL, NULL, NULL, NULL, ss);
if (nRes != RTNORM) return false;
Adesk::Int32 lLen = 0;
acedSSLength(ss, &lLen);
if (!lLen) return false;
AcDbObjectId id;
acedSSName(ss, 0, ent);
acdbGetObjectId(id, ent);
AcDbEntity *pEnt(NULL);
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
{
AecDbEwPipe* pWpipe = AecDbEwPipe::cast(pEnt);
if (pWpipe)
{
AecDbObjXDataMap* pXDataMap = pWpipe->GetSpecialtyData();
if (pXDataMap) xmap = *pXDataMap;
// TCHAR* pszLayer = pWpipe->layer();
// layer = pszLayer;
// acutDelString(pszLayer);
pXDataMap->GetAt(PIPE_SYS,layer);
double dEl = pWpipe->GetElevation(0);
xmap.SetAt(PIPE_EL,dEl);
}
pEnt->close();
}
acedSSFree(ss);
return true;
}
bool PipelineTools::getPipelineParam(WPipe::PipeParam & param, CString & layer)
{
ads_name ss, ent;
struct resbuf rb;
TCHAR szBuf[64];
rb.restype = 0;
_tcscpy(szBuf, _T("AEC_EWPIPE"));
rb.resval.rstring = szBuf;
rb.rbnext = NULL;
int nRes = acedSSGet(NULL, NULL, NULL, NULL, ss);
if (nRes != RTNORM) return false;
Adesk::Int32 lLen = 0;
acedSSLength(ss, &lLen);
if (!lLen) return false;
AcDbObjectId id;
acedSSName(ss, 0, ent);
acdbGetObjectId(id, ent);
AcDbEntity *pEnt(NULL);
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
{
AecDbEwPipe* pWpipe = AecDbEwPipe::cast(pEnt);
if (pWpipe)
{
WPipe::PipeParam* pParam = pWpipe->GetPipeParam();
::memset(&param, 0, sizeof(WPipe::PipeParam));
::memcpy(&param, pParam, sizeof(WPipe::PipeParam));
//TCHAR* pszLayer = pWpipe->layer();
//layer = pszLayer;
//acutDelString(pszLayer);
layer = pParam->szSys;
}
pEnt->close();
}
acedSSFree(ss);
return true;
}
bool PipelineTools::setLayerSys(CUIISQLiteServer *pDb, CStringArray & ar)
{
if (!pDb) return false;
CAcModuleResourceOverride myResources;
//CWSysLayCfgDlg wsysDlg;
CPipeSystemSettingDlg wsysDlg;
int nRes = wsysDlg.DoModal();
if (nRes != IDOK) return false;
//显示当前图层系统
CString sSQL, sStd(CoreTools::getCurrentPipeSysTblName());
//sSQL = _T("select tablename from wpipecfg where currstd=1");
//pDb->GetSelData(sSQL, sStd);
sSQL.Format(_T("select distinct system from %s"), sStd);
pDb->GetSelData(sSQL, ar);
return true;
}
bool PipelineTools::getLayerSys(CUIISQLiteServer * pDb, CStringArray & ar)
{
//显示当前图层系统
CString sSQL, sStd(CoreTools::getCurrentPipeSysTblName());
//sSQL = _T("select tablename from wpipecfg where currstd=1");
//pDb->GetSelData(sSQL, sStd);
sSQL.Format(_T("select distinct system from %s"), sStd);
pDb->GetSelData(sSQL, ar);
return true;
}
bool PipelineTools::createSysAllLayer(CUIISQLiteServer *pDb, LPCTSTR pszCurrSys)
{
if (pDb == NULL) return FALSE;
bool bSuccess = FALSE;
CString sSQL, sTablename(CoreTools::getCurrentPipeSysTblName());
//sSQL = _T("select tablename from wpipecfg where currstd=1");
//if (pDb->GetSelData(sSQL, sTablename))
if (!sTablename.IsEmpty())
{
//LAYKEY LAYNAME PIPESYS SYSTEM COLOR LINETYPE LINEWIDTH
//11 废水管线中心线 管线中心线 废水 4 Continuous:________ 0
sSQL.Format(_T("select layname,pipesys,color,linetype,linewidth,dimkey from [%s] where system='%s'"), sTablename, pszCurrSys);
CUIIValueTable table;
pDb->GetSelData(sSQL, table);
//所定文档
if (acDocManager->lockDocument(curDoc()) != Acad::eOk)
return FALSE;
int nIndex = -1;
AcDbObjectId idLayer, idLntype;
CStringArray arVals;
CString sLayName, sPipeSys, sColor, sLineType, sLineWidth,sDimkey, sTemp;
AcCmColor cr;
AcDbLayerTableRecord* pLayRec = NULL;
for (int i = 0; i < table.GetTableLogicSize(); i++)
{
arVals.RemoveAll();
table.GetValueRecord(i, arVals);
if (arVals.GetSize() >= 6)
{
idLayer = PipelineTools::makeLayer(arVals.GetAt(0));
sTemp = arVals.GetAt(3);
sDimkey = arVals.GetAt(5);
nIndex = sTemp.Find(_T(':'));
sLineType = _T("Continuous");
if (nIndex != -1)
{
sLineType = sTemp.Left(nIndex);
}
if (sLineType.CompareNoCase(_T("GAS_LINE") ) == 0 &&
!sDimkey.IsEmpty())
{
idLntype = PipelineTools::initShLineType(sLineType,sDimkey);
}
else
{
idLntype = PipelineTools::initLineType(sLineType);
}
//图层设置
if (Acad::eOk == acdbOpenObject((AcDbObject*&)pLayRec, idLayer, AcDb::kForWrite))
{
pLayRec->setLinetypeObjectId(idLntype);
cr.setColorIndex(_ttoi(arVals.GetAt(2)));
pLayRec->setColor(cr);
pLayRec->setDescription(arVals.GetAt(1));
pLayRec->setLineWeight((AcDb::LineWeight)_ttoi(arVals.GetAt(4)));
pLayRec->close();
bSuccess = TRUE;
}
}
}
acDocManager->unlockDocument(curDoc());
}
return bSuccess;
}
AcDbObjectId PipelineTools::getSysLayer(CUIISQLiteServer *pDb,LPCTSTR pszCurrSys)
{
bool bSuccess = FALSE;
CString sSQL, sTablename(CoreTools::getCurrentPipeSysTblName());
//sSQL = _T("select tablename from wpipecfg where currstd=1");
AcDbObjectId idLayer;
//if (pDb->GetSelData(sSQL, sTablename))
if (!sTablename.IsEmpty())
{
//LAYNAME PIPESYS SYSTEM COLOR LINETYPE LINEWIDTH
//废水管线中心线 管线中心线 废水 Continuous:________ 0
sSQL.Format(_T("select layname,pipesys,color,linetype,linewidth,dimkey from [%s] where system='%s'"), sTablename, pszCurrSys);
CUIIValueTable table;
pDb->GetSelData(sSQL, table);
CStringArray arVals;
table.GetValueRecord(0, arVals);
AcDbObjectId idLntype;
CString sLayName, sPipeSys, sColor, sLineType, sLineWidth,sDimkey, sTemp;
AcCmColor cr;
AcDbLayerTableRecord* pLayRec = NULL;
if (arVals.GetSize() >= 6)
{
idLayer = PipelineTools::makeLayer(arVals.GetAt(0));
sTemp = arVals.GetAt(3);
sDimkey = arVals.GetAt(5);
int nIndex = sTemp.Find(_T(':'));
sLineType = _T("Continuous");
if (nIndex != -1)
{
sLineType = sTemp.Left(nIndex);
}
if (sLineType.CompareNoCase(_T("GAS_LINE") ) == 0 &&
!sDimkey.IsEmpty())
{
idLntype = PipelineTools::initShLineType(sLineType,sDimkey);
}
else
{
idLntype = PipelineTools::initLineType(sLineType);
}
//图层设置
if (Acad::eOk == acdbOpenObject((AcDbObject*&)pLayRec, idLayer, AcDb::kForWrite))
{
pLayRec->setLinetypeObjectId(idLntype);
cr.setColorIndex(_ttoi(arVals.GetAt(2)));
pLayRec->setColor(cr);
pLayRec->setDescription(arVals.GetAt(1));
pLayRec->setLineWeight((AcDb::LineWeight)_ttoi(arVals.GetAt(4)));
pLayRec->close();
bSuccess = TRUE;
}
}
}
return idLayer;
}
bool PipelineTools::getPipeSysRecord(CUIISQLiteServer * pDb, LPCTSTR pszCurrSys,CStringArray& arVals)
{
if (pDb == NULL) return FALSE;
bool bSuccess = FALSE;
CString sSQL, sTablename(CoreTools::getCurrentPipeSysTblName());
//sSQL = _T("select tablename from wpipecfg where currstd=1");
//if (pDb->GetSelData(sSQL, sTablename))
if (!sTablename.IsEmpty())
{
//LAYKEY LAYNAME PIPESYS SYSTEM COLOR LINETYPE LINEWIDTH
//11 废水管线中心线 管线中心线 废水 4 Continuous:________ 0
sSQL.Format(_T("select layname,pipesys,color,linetype,linewidth from [%s] where system='%s'"), sTablename, pszCurrSys);
pDb->GetSelData(sSQL, arVals);
}
return arVals.IsEmpty() ? false : true;
}
bool PipelineTools::setPipelineMaterial(CUIISQLiteServer * pDb, CStringArray & arPipe, CStringArray & arFitting)
{
if (!pDb) return false;
CAcModuleResourceOverride myResources;
CAddMeritialDlg addMDLg;
addMDLg.SetDbServer(pDb);
int nRes = addMDLg.DoModal();
if (nRes != IDOK) return false;
CString sSQL;
if (!addMDLg.m_sPipeM.IsEmpty())
{
sSQL.Format(_T("insert into AecMaterial ([类型],[材质代号],[材质]) values ('管道','%s','%s')"),
addMDLg.m_sPipeMN, addMDLg.m_sPipeM);
pDb->ExecuteSQL(sSQL);
}
if (!addMDLg.m_sFitM.IsEmpty())
{
sSQL.Format(_T("insert into AecMaterial ([类型],[材质代号],[材质]) values ('管件','%s','%s')"),
addMDLg.m_sFitMN, addMDLg.m_sFitM);
pDb->ExecuteSQL(sSQL);
}
if (!addMDLg.m_sFlangM.IsEmpty())
{
sSQL.Format(_T("insert into AecMaterial ([类型],[材质代号],[材质]) values ('法兰','%s','%s')"),
addMDLg.m_sFlanMN, addMDLg.m_sFlangM);
pDb->ExecuteSQL(sSQL);
}
sSQL = _T("select [材质] from AecMaterial where [类型]='管道'");
pDb->GetSelData(sSQL, arPipe);
sSQL = _T("select [材质] from AecMaterial where [类型]='管件'");
pDb->GetSelData(sSQL, arFitting);
return true;
}
bool PipelineTools::getPipelineMaterial(CUIISQLiteServer * pDb, CStringArray & arPipe, CStringArray & arFitting)
{
CString sSQL;
sSQL = _T("select [材质] from AecMaterial where [类型]='管道'");
pDb->GetSelData(sSQL, arPipe);
sSQL = _T("select [材质] from AecMaterial where [类型]='管件'");
pDb->GetSelData(sSQL, arFitting);
return true;
}
bool PipelineTools::getSysByLayer(CUIISQLiteServer * pDb, LPCTSTR pszLayer, CString &sys)
{
if (!pDb) return false;
CString sSQL;
//sSQL = _T("select tablename from wpipecfg");
//CStringArray arVals;
//pDb->GetSelData(sSQL, arVals);
CString sTable(CoreTools::getCurrentPipeSysTblName()), sSys, sSysTmp;
//for (int i = 0; i < arVals.GetSize(); i++)
if (!sTable.IsEmpty())
{
// sTable = arVals.GetAt(i);
sSQL.Format(_T("select system from [%s] where layname='%s'"), sTable, pszLayer);
if (pDb->GetSelData(sSQL, sSys))
{
if (!sSys.IsEmpty())
{
sys = sSys;
return true;
}
}
}
return false;
}
void PipelineTools::initEquSectionBlock(AecDbEwEquipment * pEqu
, LPCTSTR pszTB
, LPCTSTR pszLR
, LPCTSTR pszFB
, LPCTSTR pszENWS
, LPCTSTR pszESWN)
{
if (!pEqu) return;
CString ss(FilePath::GetEqu2dDir() + _T("\\"));
if (pszTB && Band2dForEqu(pEqu, ss + pszTB, AecDbEwEquipment::eTopBottom))
acutPrintf(_T("\n仰视/俯视 剖面绑定成功。"));
if (pszLR && Band2dForEqu(pEqu, ss + pszLR, AecDbEwEquipment::eLeftRight))
acutPrintf(_T("\n左视/右视 剖面绑定成功。"));
if (pszFB && Band2dForEqu(pEqu, ss + pszFB, AecDbEwEquipment::eFrontBack))
acutPrintf(_T("\n前视/后视 剖面绑定成功。"));
if (pszENWS && Band2dForEqu(pEqu, ss + pszENWS, AecDbEwEquipment::eENWS))
acutPrintf(_T("\n东北轴侧/西南轴侧 剖面绑定成功。"));
if (pszESWN && Band2dForEqu(pEqu, ss + pszESWN, AecDbEwEquipment::eESWN))
acutPrintf(_T("\n东南轴侧/西北轴侧 剖面绑定成功。"));
}
bool PipelineTools::updateEquSection(CUIISQLiteServer *pDb, LPCTSTR sIDEqu)
{
if (!pDb) return false;
if (!sIDEqu) return false;
CAcModuleResourceOverride myResources;
CEquBand2D dlg;
if (dlg.DoModal() != IDOK) return false;
CString sSql(_T(""));
sSql.Format(_T("UPDATE aec_package")
_T(" SET TopBottom='%s', LeftRight='%s', FrontBack='%s', ENWS='%s', ESWN='%s'")
_T(" WHERE ID='%s'")
, dlg.m_sTB
, dlg.m_sLR
, dlg.m_sFB
, dlg.m_sENWS
, dlg.m_sESWN
, sIDEqu);
if (pDb->ExecuteSQL(sSql))
AfxMessageBox(_T("设备元件设置剖面成功!"));
else
AfxMessageBox(_T("设备元件设置剖面失败!"));
return true;
}