.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 11 of 13 (206 Views)

Re: CommandEnded Event handling with OVERKILL

02-03-2013 09:45 PM in reply to: Alexander.Rivilis

HI, Alex.

 

I have tried one that you suggested with the following code.

 

private void SelectEntitiesOnLayer(Document doc, string layerName)
{
    Editor ed = doc.Editor;

    // Build a filter list so that only entities
    // on the specified layer are selected
    //TypedValue[] tvs = new TypedValue[1] { new TypedValue((int)DxfCode.LayerName, layerName) };
    TypedValue[] tvs = new TypedValue[2] { new TypedValue((int)DxfCode.LayerName, layerName), new TypedValue((int)DxfCode.LayoutName, "Model") };
    SelectionFilter sf = new SelectionFilter(tvs);
    PromptSelectionResult psr = ed.SelectAll(sf);
}

[CommandMethod("MyOverkill")]
public void MyOverkill()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    SelectEntitiesOnLayer(doc, LayerName.TIN);
    doc.SendStringToExecute("-overkill\np\n\n\n", true, false, false);
}

[CommandMethod("MoreWork")]
public void MoreWork()
{
    DoSomeWork();
}

[CommandMethod("Test")]
public void Test()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    string cmd = @"(command ""MyOverkill"")(while(>(getvar ""cmdactive"")0)(command pause))(command ""MoreWork"") ";
    doc.SendStringToExecute(cmd, true, false, true);
}

 

As you can see, I am expecting DoSomeWork() gets called after "MyOverkill"

Let's say DoSomeWork() is nothing more than poping up the alert.

If I call "Test" command the aleart box pops up immediately, then "-overkill" gets called after.

Which is opposite to what I expected.

 

Did I do something wrong? =(

 

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 12 of 13 (201 Views)

Re: CommandEnded Event handling with OVERKILL

02-03-2013 10:56 PM in reply to: dynamicscope

What about this code:

[CommandMethod("Test")]
public void Test()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    string cmd;
    cmd = "-overkill\n_p\n\n\n"; 
    doc.SendStringToExecute(cmd, true, false, true);
    cmd = "(while(>(getvar \"cmdactive\")0)(command pause))\n";
    doc.SendStringToExecute(cmd, true, false, true);    
    cmd = "MoreWork\n";
    doc.SendStringToExecute(cmd, true, false, true);    
}

 ?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 13 of 13 (194 Views)

Re: CommandEnded Event handling with OVERKILL

02-04-2013 01:24 AM in reply to: Alexander.Rivilis

Thank you, Alex~!!

 

Super awesome~!

Looks like this code is working~!! =)

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.