using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
namespace AcadTest
{
public class TestBoundedPlane
{
[CommandMethod("TestBoundedPlane")]
public void Run()
{
Document adoc = Application.DocumentManager.MdiActiveDocument;
Editor ed = adoc.Editor;
if (GetPoint(ed, "\nFirst1:", out Point3d firstPt1)
&& GetPoint(ed, "\nSecond1:", out Point3d secondPt1)
&& GetPoint(ed, "\nThird1:", out Point3d thirdPt1)
&& GetPoint(ed, "\nFirst2:", out Point3d firstPt2)
&& GetPoint(ed, "\nSecond2:", out Point3d secondPt2)
&& GetPoint(ed, "\nThird2:", out Point3d thirdPt2))
{
BoundedPlane
first = new BoundedPlane(firstPt1, secondPt1, thirdPt1),
second = new BoundedPlane(firstPt2, secondPt2, thirdPt2);
LineSegment3d inters = first.IntersectWith(second);
if (inters != null)
{
ed.WriteMessage
("\nLine. Start point: {0}, end point: {1}",
inters.StartPoint,
inters.EndPoint);
}
else
{
ed.WriteMessage("\nNot intersected!");
}
}
}
static bool GetPoint(Editor ed, string msg, out Point3d pt)
{
Matrix3d ucs2wcs = ed.CurrentUserCoordinateSystem;
PromptPointResult ppr1
= ed.GetPoint(new PromptPointOptions(msg));
if (ppr1.Status != PromptStatus.OK)
{
pt = default(Point3d);
return false;
}
pt = ppr1.Value.TransformBy(ucs2wcs);
return true;
}
}
}