Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I just want to draw a pline on the screen and get the pline objectid and continue the next step code, but it seems the sending command 'pline' always starts in the end of all the code. could you help me to solve this problem?
the following code was copy from kean's blog, I try to add one line of code after the 'PLINE' command, but alert dialog shows before let user select pline point.
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
namespace revMarkCreate
{
public class MyPlineCmds1 : IExtensionApplication
{
// Flag used to check whether it's our command
// that launched PLINE
private static bool myCommandStarted = false;
public void Initialize()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
doc.CommandEnded += new CommandEventHandler(plineCommandEnded);
}
public void Terminate()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
doc.CommandEnded -= new CommandEventHandler(plineCommandEnded);
}
[CommandMethod("MYPOLY1")]
public void MyPoly()
{
// Set the flag and launch PLINE
myCommandStarted = true;
Document doc = Application.DocumentManager.MdiActiveDocument;
doc.SendStringToExecute("_PLINE ", false, false, false);
//I want to let the 'PLINE' command run before the alertdialog shows
Application.ShowAlertDialog("test");
}
private void plineCommandEnded(object sender, CommandEventArgs e)
{
if (myCommandStarted && e.GlobalCommandName.ToUpper() == "PLINE")
{
// We're just performing a simple check, so OK..
// We could launch a follow-on command, if needed
Document doc = Application.DocumentManager.MdiActiveDocument;
PromptSelectionResult lastRes = doc.Editor.SelectLast();
if (lastRes.Value != null && lastRes.Value.Count == 1)
{
doc.Editor.WriteMessage("\nThe entity is: " + lastRes.Value[0].ObjectId);
}
myCommandStarted = false;
}
}
}
}
Solved! Go to Solution.