.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 11 of 13 (189 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,398
Registered: ‎04-09-2008
Message 12 of 13 (184 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 (177 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~!! =)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community