Hi,
I had to implement a 'pause' within a command today.
From a modeless dialog (palette) button I needed to launch the DTEXT command and wanted to avoid the user to specify size and rotation.
I use doc.SendStringToExecute because it's the only way I found to give the focus to AutoCAD window immediately: when I try the ed.GetPoint first, I have to click twice before being able to specify a point.
So, here's the way I figured it using a CommandWillStart event handler:
private void cmdDoIt_Click(object sender, EventArgs e)
{
using (DocumentLock docLock = _doc.LockDocument())
{
// register the event handler
_doc.CommandWillStart += new CommandEventHandler(PauseForPoint);
// launch the command
_doc.SendStringToExecute("_dtext ", true, false, false);
}
}
void PauseForPoint(object sender, CommandEventArgs e)
{
// prompt for a point
PromptPointOptions ppo = new PromptPointOptions("\nSpecify the text start point: ");
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status == PromptStatus.OK)
{
// continue the command
Autodesk.AutoCAD.Geometry.Point3d pt = ppr.Value;
string cmd = string.Format("{0},{1},{2} ", pt.X, pt.Y, pt.Z);
_doc.SendStringToExecute(cmd, false, false, false);
}
else
// cancel the command (escape)
_doc.SendStringToExecute("\x1B", false, false, false);
// unregister the event handler
_doc.CommandWillStart -= PauseForPoint;
}