By Fenton Webb
An AcDbPolyline is derived from AcDbCurve, a curve uses Parameter values to define its geometry. For a Polyline, the Parameter start value is 0 and the end parameter is the total number of vertices –1. Those parameter values can be utilized to quickly and easily work out mid points, like this:
Acad::ErrorStatus getMidPointOnEachSegOfCrv(AcDbCurve *pCurve) { if(!pCurve->isKindOf(AcDbCurve::desc())) { acutPrintf(L"nSelected entity is not a CURVE derived object"); return Acad::eInvalidInput; } Acad::ErrorStatus es; double startParam, endParam; // get the start param, usually it starts at 0 or 1 es = pCurve->getStartParam( startParam ); acutPrintf(L"nstartParam is %fl", startParam); // get the end param, for a polyline it's the total number of // vertex's -1 es = pCurve->getEndParam( endParam ); acutPrintf(L"nendParam is %fl", endParam); // now loop the parameters, adding 1.0 each iteration for(double i=startParam; igetPointAtParam(i+.5, pt); if (es == Acad::eOk) acutPrintf(L"n%f,%f,%f", pt[0], pt[1], pt[2]); } return Acad::eOk; }

Leave a Reply to Owen WengerdCancel reply