Commands - C# - Entity or Selection Set as Parameter

Hello, everyone.

I'm trying to execute a command using C# in BricsCad Pro V22 x64. The problem that I'm encountering, is happening when I try to send a Selection Set or a Entity to a Editor.Command as a parameter.

It works in Autocad with Entity and Selection Set (https://www.keanw.com/2015/08/passing-autocad-objects-to-commands-called-via-net.html), but it does not work in BricsCad. When I run the code in Brics, it shows the error: "unable to recognise object". Then I must manually select something. This is the code I'm using:

using (Transaction tr = db.TransactionManager.StartTransaction())
{
PromptEntityResult selRes = Editor.GetEntity("Select something:");
if (selRes.Status == PromptStatus.OK)
{
Entity ent = tr.GetObject(selRes.ObjectId, OpenMode.ForRead) as Entity;
Editor.Command("._REVCLOUD", "_E", ent, "");
}
}

Does anyone know what can I do? It looks like that BricsCad doesn't support that way of calling a command with a Entity or Selection Set. But there must be one or another way to do that. The ideia of the code is get a entity (or many) and turn it in a revision cloud. Thanks in advance.

Comments

  • Create a SelectionSet and use it to call the REVCLOUD command

    var ss = SelectionSet.FromObjectIds(new ObjectId[] { selRes.ObjectId });

    ed.Command("_.REVCLOUD", "", ss, "");
  • Editor.Command("._REVCLOUD", "_E", ss, "");
  • Thanks for the answer. But I still receive the message: Unable to recognize input. Then I must again select something. I used the following now:

    [CommandMethod("try_cloud")]
    public static void cloudTest()
    {
    Document docum = Application.DocumentManager.MdiActiveDocument;
    Database datab = docum.Database;
    Editor editor = docum.Editor;

    using (Transaction tr = datab.TransactionManager.StartTransaction())
    {
    PromptEntityResult selRes = editor.GetEntity("Select something:");
    if (selRes.Status == PromptStatus.OK)
    {
    var ss = SelectionSet.FromObjectIds(new ObjectId[] { selRes.ObjectId });
    editor.Command("._REVCLOUD", "_E", ss, ""); //"Unable to recognize input" message received
    }
    }
    }
  • Try this code, it works for me with no errors generated !

    [CommandMethod("RVCL")]
    public static void cloudTest()
    {
    Document docum = Application.DocumentManager.MdiActiveDocument;
    Editor editor = docum.Editor;

    PromptEntityResult selRes = editor.GetEntity("Select something:");

    if (selRes.Status == PromptStatus.OK)
    SelectionSet ss = SelectionSet.FromObjectIds(new ObjectId[] { selRes.ObjectId });
    {
    ResultBuffer rb = new ResultBuffer();


    rb.Add(new TypedValue((int)LispDataType.Text, "_.REVCLOUD"));
    rb.Add(new TypedValue((int)LispDataType.Text, ""));
    rb.Add(new TypedValue((int)LispDataType.SelectionSet, ss));
    rb.Add(new TypedValue((int)LispDataType.Text, ""));

    Bricscad.Global.Editor.Command(rb);
    }
    }
  • Sorry typing error correction needed....selection set creation must be within the IF block......

    [CommandMethod("RVCL")]
    public static void cloudTest()
    {
    Document docum = Application.DocumentManager.MdiActiveDocument;
    Editor editor = docum.Editor;

    PromptEntityResult selRes = editor.GetEntity("Select something:");

    if (selRes.Status == PromptStatus.OK)
    {
    SelectionSet ss = SelectionSet.FromObjectIds(new ObjectId[] { selRes.ObjectId });
    ResultBuffer rb = new ResultBuffer();

    rb.Add(new TypedValue((int)LispDataType.Text, "_.REVCLOUD"));
    rb.Add(new TypedValue((int)LispDataType.Text, ""));
    rb.Add(new TypedValue((int)LispDataType.SelectionSet, ss));
    rb.Add(new TypedValue((int)LispDataType.Text, ""));

    Bricscad.Global.Editor.Command(rb);
    }
    }
  • Thank you, so much. This works perfectly. No erros.