ads_point fromPt;
int rc = acedGetPoint(NULL, _T("\nPick first point"), fromPt);
if(rc != RTNORM)
return;
ads_point toPt;
rc = acedGetPoint(NULL, _T("\nPick second point"), toPt);
if(rc != RTNORM)
return;
int colorIndex = 2;
// Compute the mirror vector
ads_point fromPtMirror;
ads_point_set(fromPt, fromPtMirror);
fromPtMirror[1] *= -1.0;
ads_point toPtMirror;
ads_point_set(toPt, toPtMirror);
toPtMirror[1] *= -1.0;
struct resbuf *vlist;
// Build ResBuf
vlist = acutBuildList(
RTSHORT, colorIndex, // Color
RTPOINT, fromPt, // Actual vector
RTPOINT, toPt,
RTPOINT, fromPtMirror, // Mirror vector
RTPOINT, toPtMirror,
RTNONE);
// Using aced method to create temporary graphics.
// NULL for identity transformation matrix
rc = acedGrVecs(vlist, NULL);
// Cleanup
acutRelRb(vlist);
Here is the equivalent of the above code using the AutoCAD .Net API :
private const int RTPOINT = 5002;
private const int RTSHORT = 5003;
Document activeDoc =
Application.DocumentManager.MdiActiveDocument;
Editor ed = activeDoc.Editor;
PromptPointResult ppr1 = ed.GetPoint("\nPick first point");
if (ppr1.Status != PromptStatus.OK)
return;
PromptPointResult ppr2 = ed.GetPoint("\nPick second point");
if (ppr2.Status != PromptStatus.OK)
return;
Point3d sp = ppr1.Value;
Point3d ep = ppr2.Value;
int colorIndex = 1;
using (ResultBuffer resBuf = new ResultBuffer())
{
resBuf.Add(new TypedValue(RTSHORT, colorIndex));
// The actual vector
resBuf.Add(new TypedValue(
RTPOINT,
new Point2d(sp.X, sp.Y)
)
);
resBuf.Add(new TypedValue(
RTPOINT,
new Point2d(ep.X, ep.Y)
)
);
// and its mirror about x axis
resBuf.Add (new TypedValue(
RTPOINT,
new Point2d(sp.X, -sp.Y)
)
);
resBuf.Add(new TypedValue(
RTPOINT,
new Point2d(ep.X, -ep.Y)
)
);
ed.DrawVectors(resBuf, Matrix3d.Identity);
}