折断线打断点求法

// 起点、终点、打断点
AcGePoint3d pnt1st;
acedGetPoint(NULL, _T("指定第一点"), asDblArray(pnt1st));
AcGePoint3d pnt2nd;
acedGetPoint(asDblArray(pnt1st), _T("指定第二点"), asDblArray(pnt2nd));
AcGePoint3d pntBreak;
acedGetPoint(NULL, _T("指定打断点"), asDblArray(pntBreak));

// 转换到WCS坐标系
AcGePoint3d pnt1stInWcs;
acdbUcs2Wcs(asDblArray(pnt1st), asDblArray(pnt1stInWcs), false);
AcGePoint3d pnt2ndInWcs;
acdbUcs2Wcs(asDblArray(pnt2nd), asDblArray(pnt2ndInWcs), false);
AcGePoint3d pntBreakInWcs;
acdbUcs2Wcs(asDblArray(pntBreak), asDblArray(pntBreakInWcs), false);

// 根据ViewDir求投影最近点
AcGeLine3d line(pnt1stInWcs, pnt2ndInWcs);
resbuf rbViewDir;
acedGetVar(_T("VIEWDIR"), &rbViewDir);
AcGeVector3d viewDir = asVec3d(rbViewDir.resval.rpoint);
acdbUcs2Wcs(asDblArray(viewDir), asDblArray(viewDir), true);
AcGePointOnCurve3d pntOnCurve;
line.getProjClosestPointTo(pntBreakInWcs, viewDir, pntOnCurve);
AcGePoint3d pntRet = pntOnCurve.point3d();

你可能感兴趣的:(折断线打断点求法)