Thanks fieldguy.
This is where i'm at so far. The problem with this is, although i can pick four points ,they are all of varying X and Y values, so it will be hard to calculate area. Is there a way I can do this as if i was creating a rectangle for instance? That way I could visualize the lines while selecting the points, but still obtain enough information to determine area?
Cheers
Vince
namespace Corners
{
public class Corners
{
[CommandMethod("Corners", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void GeWindowPointSelection()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
List<Point3d> points = new List<Point3d>();
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
try
{
PromptPointOptions ppo = new PromptPointOptions("\n\tSpecify a first corner: ");
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
PromptPointOptions ppo1 = new PromptPointOptions("\n\tSpecify a second corner: ");
PromptPointResult ppr1 = ed.GetPoint(ppo1);
if (ppr1.Status != PromptStatus.OK) return;
PromptPointOptions ppo2 = new PromptPointOptions("\n\tSpecify a third corner: ");
PromptPointResult ppr2 = ed.GetPoint(ppo2);
if (ppr2.Status != PromptStatus.OK) return;
PromptPointOptions ppo3 = new PromptPointOptions("\n\tSpecify a fourth corner: ");
PromptPointResult ppr3 = ed.GetPoint(ppo3);
if (ppr3.Status != PromptStatus.OK) return;
Point3d pt1 = ppr.Value;
Point3d pt2 = ppr1.Value;
Point3d pt3 = ppr2.Value;
Point3d pt4 = ppr3.Value;
double X1 = Convert.ToDouble(pt1.X);
double Y1 = Convert.ToDouble(pt1.Y);
double X2 = Convert.ToDouble(pt2.X);
double Y2 = Convert.ToDouble(pt2.Y);
double X3 = Convert.ToDouble(pt3.X);
double Y3 = Convert.ToDouble(pt3.Y);
double X4 = Convert.ToDouble(pt4.X);
double Y4 = Convert.ToDouble(pt4.Y);
/*
if (pt1.X == pt2.X || pt1.Y == pt2.Y)
{
ed.WriteMessage("\nInvalid point specification");
return;
}
*
* */
BlockTableRecord acadBTR = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
MText acadMText1 = new MText();
MText acadMText2 = new MText();
MText acadMText3 = new MText();
MText acadMText4 = new MText();
MText acadMText5 = new MText();
MText acadMText6 = new MText();
MText acadMText7 = new MText();
MText acadMText8 = new MText();
acadMText1.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 5, 0);
acadMText2.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 7, 0);
acadMText3.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 9, 0);
acadMText4.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 11, 0);
acadMText5.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 13, 0);
acadMText6.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 15, 0);
acadMText7.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 17, 0);
acadMText8.Location = new Autodesk.AutoCAD.Geometry.Point3d(12, 19, 0);
acadMText1.Contents = "Double X1 = " + X1;
acadMText2.Contents = "Double X2 = " + X2;
acadMText3.Contents = "Double X3 = " + X3;
acadMText4.Contents = "Double X4 = " + X4;
acadMText5.Contents = "Double Y1 = " + Y1;
acadMText6.Contents = "Double Y2 = " + Y2;
acadMText7.Contents = "Double Y3 = " + Y3;
acadMText8.Contents = "Double Y4 = " + Y4;
acadBTR.AppendEntity(acadMText1);
acadBTR.AppendEntity(acadMText2);
acadBTR.AppendEntity(acadMText3);
acadBTR.AppendEntity(acadMText4);
acadBTR.AppendEntity(acadMText5);
acadBTR.AppendEntity(acadMText6);
acadBTR.AppendEntity(acadMText7);
acadBTR.AppendEntity(acadMText8);
tr.Commit();
ed.Regen();
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
}
}
}
}
}