Custom selection of AutoCAD Objects

Hi all
Have written a Node for custom selection for AutoCAD Objects in C#…
It works well like expected…
Only thing is by automatic running mode of the Dynamo script it does not react by changes of AutoCAD objects (move or copy etc.) like the normal selection for e.g. Select all objects on Layer…
Does anybody can help me in that?
Does anybody have an idea what I can do?
Thanks in advance

Hi @mat77,

Maybe look in the Autodesk.AutoCAD.DynamoApp.Services namespace (AcDynamoServices DLL). There are some events that might help.

Hi mzjensen

Thank you very much for your idea will check that.
Have checked also your great work on github…
You have there a selection for AutoCAD Objects but think manually selection by user?
It will be not easy for me to find out what I have to do / add…
My goal is to select AutoCAD objects by dxfstartname because of custom AutoCAD objects which I have already but no at the end I only need the handle which re-run the Dynamo script when objects in AutoCAD Dwg will be modified copied deleted added… Maybe you can help me with an example?

What selection method do you use? Some will only work in the visible view of AutoCAD. It ignores objects that are not visible.

My code is just like this

public static IList<dynACNodes.Object> GetAcadEntitiesByDxfName(string DxfName)
IList<dynACNodes.Object> output = new List<dynACNodes.Object>();

        dynACNodes.Document document = dynACNodes.Document.Current;
        if (document == null) { throw new Exception("Current document is null."); }

        using (dynAppServ.DocumentContext ctx = new dynAppServ.DocumentContext(document.AcDocument))
            var objects = document.ModelSpace.Objects;
            acDbServ.Transaction tr = ctx.Transaction;

            foreach (dynACNodes.Object obj in objects)

                var Ent = tr.GetObject(obj.InternalObjectId, acDbServ.OpenMode.ForRead) as acDbServ.Entity;

                if (obj.InternalObjectId.ObjectClass.DxfName.Contains(DxfName))


        return output;

Think have to implement something from
AcDynamoServices DrawingReactors but here I’m lost …
Would like to reach similar reaction like the static Methods AutoCADNodes .dll SelectionByQuery Class
Can anyone help please?

Hmmm, I wrote in recent days methods that let manage “search patterns” by dxf-codes. Look that code or class Selection at my package Civil3D.CustomNodes.
Script’s nodes below

Hi Georg
Thanks very very much for your answer
Question before I check your code…
Does your selection update when Entities in AutoCAD will be changed? For example moved copied etc?
I mean when the Dynamo script is running in automatically running mode?
Thanks in advance

If these methods using as dynamo’s nodes once-- no. They returning drawing’s objects at moment of node’s initiation. From other side, if place that node between some “cycle function” it will be return new objects too (theoretically); I don’t tested that, because prefer work wish “package procedures” in code only (no in Dynamo’s environmental).

Thanks again for your answer
My code posted above works already fine…
My only problem is that I’m looking for a handle that my selection reacting automatically after an object change in AutoCAD the Dynamo script should be re-run like the standard Dynamo Autocad selection objects on Layer does.

Try to use Civil 3D API only without dynamo. F.e. save edits in node and re-querry what you needing (in that method) … and you will not reload script