Files
envi-code/SourceCode/Code2026/tg_shs/shs_siteplan/ParkingStatisticCmd.cpp
T
2026-09-28 15:28:50 +08:00

57 lines
1.6 KiB
C++

#include "stdafx.h"
extern Acad::ErrorStatus CreateTextStyle(AcDbObjectId& resultId,
const CString csTsName,
const CString szFlNm,
const CString szBigFlNm,
double dTextWidth,
double dTextHeight,
double xScale,
AcDbDatabase* pDB);
void ParkingStatisticCmd()
{
while (true)
{
PickSet ss(SS_FREE);
RBList rbMark(RTDXF0, _T("POLYLINE,LWPOLYLINE"), 8, LAY_PKNG_TSRP, NULL);
int nRetCode=SelectEntities(_T("\n请选择停车位<退出>:"), ss, rbMark);
if (nRetCode != RTNORM) // 命令结束
{
return;
}
CString strOut;
int nParkingNum = ss.Length();
strOut.Format(_T("共%d个停车位"),nParkingNum);
acutPrintf(strOut);
AcGePoint3d ptMarkerPos;
nRetCode = acedGetPoint(NULL,_T("\n请点取标注位置<退出>:"),asDblArray(ptMarkerPos));
if (nRetCode == RTNORM)//标注车位量数
{
ptMarkerPos = Ucs2Wcs(ptMarkerPos);
TDbText *pText = new TDbText;
XString sValue(256);
sValue<<XString(_T("%d辆"),nParkingNum);
pText->SetText(sValue);
pText->SetRotation(Ucs2Wcs(0));
pText->SetLocation(ptMarkerPos);
//设置文字默认样式和字高
AcDbObjectId idTextStyle = InitTextStyle(TS_PKNGTSRP);
if (idTextStyle.isValid())
pText->SetStyleId(idTextStyle);
else
pText->SetStyleId(acdbCurDwg()->textstyle());
double dTextHeight = GetTextHeightByTs(TS_PKNGTSRP);
if (dTextHeight < 1E-6)
dTextHeight = 10;
pText->SetHeight(dTextHeight);
pText->setLayer(InitLayer(LAY_PKNG_SING));
pText->SetAlignment(XExplodeDraw::kBottomCenter);
AddToModelSpace(pText, Adesk::kTrue);
}
else
{
return;
}
}
}