I am trying to rewrite the C# code for the GetPoint Method found in AutoCAD .NET Developers Guide/Prompt for User Input.
I rewriting it in hopes of better understanding it...which I think it working
But I am stuck on the rubber portion. I can pick the two points and draw the line...but once I pick the first point I want the rubber band line...not getting it.
[CommandMethod("UserPoint")]
public static void UserPoint()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
PromptPointOptions usrPointOpts = new PromptPointOptions("Enter the start point of the line: "); //prompt for point
PromptPointResult usrPointRes = acDoc.Editor.GetPoint(usrPointOpts); //get user point
Point3d usrStart = usrPointRes.Value; //store user value
PromptPointOptions usrEndPointOpts = new PromptPointOptions("\nEnter the end point of the line: "); //prompt for point
[color=red] //set a rubber band line **************NOT WORKING********************[/color]
usrPointOpts.UseBasePoint = true;
usrPointOpts.BasePoint = usrStart;
PromptPointResult usrEndPointRes = acDoc.Editor.GetPoint(usrEndPointOpts); //get user point
Point3d usrEnd = usrEndPointRes.Value; //store user value
//start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartOpenCloseTransaction())
{
BlockTable acBlkTbl;
BlockTableRecord acBlkTblRec;
//open model space for write
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
as BlockTableRecord;
//define the new line
Line usrLine = new Line(usrStart, usrEnd);
usrLine.SetDatabaseDefaults();
//add new line to the drawing
acBlkTblRec.AppendEntity(usrLine);
acTrans.AddNewlyCreatedDBObject(usrLine, true);
//commit the changes and dispose of the transaction
acTrans.Commit();
}
}
(side question, how do I add color to a portion of code?)
As usual, any help is appreciated.