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

173 lines
4.2 KiB
C++

#include "StdAfx.h"
#include "DbVPipeDim.h"
//***************************************************************************************************
// 编号增减
//***************************************************************************************************
void PlusMinusSerial(BOOL bPlus)
{
// g_ssPickFirst.Free();
RBList rbMask(RTDXF0, _T("ATS_PIPE,ATS_VPIPEDIM"), NULL);
Entity entPipe, entSel;
CString csPrompt;
if(bPlus)
csPrompt = _T("\n请选择要编号加1的立管或编号:<退出>");
else
csPrompt = _T("\n请选择要编号减1的立管或编号:<退出>");
if(SelectEntity(csPrompt, entSel, rbMask) != RTNORM)
return;
if(!IsPipeVertical(entSel))
{
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbVPipeDim, pDim);
if (pDim != NULL)
{
AcDbObjectId idDim = pDim->GetVPipeId();
ads_name name;
acdbGetAdsName(name,idDim);
entPipe = name;
}
else
return;
OPENOBJ_END();
}
else
entPipe = entSel;
char szLay[256];
entPipe.GetData(8, szLay);
CString csSerial = ReadXdata(entPipe, _T("PIPE-SERIAL"));
CString sFloorNum = ReadXdata(entPipe,_T("BUILDING-SERIAL"));
int newIdx = _ttoi(csSerial);
if(bPlus)
newIdx ++;
else
newIdx --;
if(newIdx == 0)
{
adsout << _T("编号为1,不能再减了。\n");
return;
}
//2007-7-6 考虑了被打断的多立管情况
AcDbObjectId id = NULL;
acdbGetObjectId(id, entPipe);
PickSet ssAllVertPipe(SS_FREE);
GetAllVertPipeByPt(ssAllVertPipe, id);
for(long i=0;i<ssAllVertPipe.Length();i++){
Entity entTmp = ssAllVertPipe[i];
WriteXdata(entTmp, _T("PIPE-SERIAL"), (const TCHAR*)(XString(_T("%d"), newIdx)));
}
UpdateMultDim(entPipe);
SHads_command(RTSTR, _T("REGEN"), RTNONE); // cet 2012.3.1 add 刷新实体
PickSet ss(SS_FREE), ssModify(SS_FREE);
RBList rbMask2(RTDXF0, _T("ATS_PIPE"), 8, szLay, NULL);
ss.Get(_T("X"), NULL, NULL, rbMask2);
long len = ss.Length();
XStringList lstSerial;
BOOL bDouble = FALSE;
for(i=0;i<len;i++){
Entity ent = ss[i];
if(ent.In(&ssAllVertPipe))
continue;
CString csSerial2 = ReadXdata(ent, _T("PIPE-SERIAL"));
CString sFloorNumT;
sFloorNumT = ReadXdata(ent,_T("BUILDING-SERIAL"));
int newIdx2 = _ttoi(csSerial2);
int idx = newIdx-1;
if(!bPlus)
idx = newIdx;
if(idx < newIdx2){
if(lstSerial.Index(csSerial2) < 0)
lstSerial.Append(tstrnew(csSerial2));
else
bDouble = TRUE;
if (sFloorNumT.CompareNoCase(sFloorNum) == 0)
ssModify += ent;
}
}
ssModify-=entPipe;
len = ssModify.Length();
if(len < 1)
return;
TCHAR szText[32];
int iLen = len;
csPrompt.Format(_T("\n发现还有%d个立管需要修改编号,是否自动更新?<Y>"), iLen);
int ret = ads_getstring(NULL, csPrompt, szText);
if(_tcsicmp(szText, _T("Y")) == 0 || _tcsicmp(szText, _T("")) == 0){
PickSet ssTmp(SS_FREE);
if(bDouble){ //发现多处同名立管编号
if(SelectEntities(_T("\n请选择立管包括的范围:<退出>"), ssTmp, rbMask2) != RTNORM)
return;
}
for(i=0;i<len;i++){
Entity ent = ssModify[i];
if(bDouble && ent.In(&ssTmp) < 1)
continue;
CString csSerial2 = ReadXdata(ent, _T("PIPE-SERIAL"));
int newIdx2 = _ttoi(csSerial2);
if(bPlus){
newIdx2++;
}
else{
newIdx2--;
}
if(newIdx2 < 1)
adsout << _T("\n提醒:有立管编号为0");
WriteXdata(ent, _T("PIPE-SERIAL"), (const TCHAR*)(XString(_T("%d"), newIdx2)));
// UpdateSerialDim(ent, csSerial2, newIdx2);
}
//更新立管标注
//更新标注
ssModify += entPipe;
PickSet ssAll(SS_FREE);
RBList rbMaskVPipe(RTDXF0, _T("ATS_VPIPEDIM"),NULL);
ssAll.Get(_T("A"),NULL,NULL,rbMaskVPipe);
long lLen = ssAll.Length();
PickSet ssRenew(SS_FREE);
for (long m = 0; m < lLen; ++m)
{
OPENOBJ_BEGIN(ssAll[m], AcDb::kForWrite, TDbVPipeDim, pDim);
if (pDim != NULL)
{
AcDbObjectId idDim = pDim->GetVPipeId();
ads_name name;
acdbGetAdsName(name,idDim);
Entity ent(name);
if (ssModify.IsInclude(ent))
{
ssRenew += ssAll[m];
pDim->RenewDimLen();
pDim->SaveCurText();
}
}
OPENOBJ_END();
}
UpdateGraphic(ssRenew);
}
}
void PlusPipeSerial()
{
PlusMinusSerial(TRUE);
}
void MinusPipeSerial()
{
PlusMinusSerial(FALSE);
}