Thanks guys, what an easy solution! Norman, thanks for writing it up in your blog, it's a valuable resource for us .NET CAD people
Here's what I've come up with in my commands class:
/// <summary>
/// Sends the command via SendStringToExecute
/// To preserve pickfirst, cancel only if there is an active command.
/// </summary>
/// <param name="cmd">The command to send.</param>
public static void Send(string cmd)
{
Document doc = CAD_App.DocumentManager.MdiActiveDocument;
if (doc == null) return;
// gotta have a space at the end.
if (!cmd.EndsWith(" ")) cmd += " ";
// check for active command
int activeCmd = Convert.ToInt32(CAD_App.GetSystemVariable("CMDACTIVE"));
if (activeCmd > 0)
{
// cancel out of it
doc.SendStringToExecute("\x03\x03", false, true, false);
}
// now send the command we want
doc.SendStringToExecute(cmd, false, true, false);
}
And it's called from a pallet with something like:
private void btnSetSize_Click(object sender, EventArgs e)
{
Commands.Send("IR_SetPipeSize");
}
There could be a problem with the back to back
SendStringToExecute calls since I think it's async, but I haven't seen any issues so far.