|
[code]void cmdDispProperty()
{
ArxDbgUiPrEntity prEnt(_T("请选择由 Pline组成的封闭多边形"), NULL);
prEnt.addAllowedClass(AcDbPolyline::desc());
if (prEnt.go() != ArxDbgUiPrBase::kOk)
{
return;
}
AcDbEntity* pEnt1 = NULL;
acdbOpenObject(pEnt1,prEnt.objectId(),AcDb::kForRead);
//获得封闭形顶点
AcDbPolyline *Polygon = NULL ;
Polygon = AcDbPolyline::cast(pEnt1);
ASSERT( Polygon != NULL );
if (Polygon == NULL)
{
AfxMessageBox(_T("线型不为多义线"));
pEnt1->close();
return;
}
if( !Polygon->isClosed() )
{
Polygon->close();
AfxMessageBox(_T("外轮廓不封闭"));
return;
}
AcGePoint3d *pPtArray;//记录外轮廓上的点
int VertNum = (int)Polygon->numVerts() ;
pPtArray = new AcGePoint3d[VertNum];
int i;
for( i = 0; i < VertNum; i ++ )
{
AcGePoint3d Temp;
Polygon->getPointAt(i,Temp);
pPtArray<i> = Temp;
}
pEnt1->close();
AcGePoint3d centroid;
GetCentroidPt(pPtArray, VertNum, centroid);
TCHAR Text[132];
_stprintf(Text, _T("%.3f"), centroid.y);
DelGroupEnt(_T("neuotrol"));
DrawElevLine2(centroid,Text,_T("Neuotrol"));
}[/code] |
|