Have I missed it or is there not a node to manually select multiple objects from model space? I only see a node to select a single object. I found nodes to select multiple in various packages, but this seem like a really basic thing that should be in core dynamo.
I think this will be even more important if Civil 3D ever includes a Dynamo Player like Revit.
You are not alone. I wanted to have select multiple objects as well but as of now I can’t find it so end up using All Objects of Type or All Objects on Layer.
The objects are now shown in Dynamo but they need to be DesignScript objects instead of AutoCAD objects. This way you can’t do anything with it.
Also the SelectImplied only works when you open Dynamo, not in Automatic or Run mode. I think SelectImplied is not the best way to select objects. It is better to manually select objects or by a filter (object type, window, property, whatever). These functions need to be programmed off course.
This is my first attempt to write a Python script. So don’t ask me to make it better
Thanks Anton. I’m at a similar state. Here is my code to prompt you to select the multiple objects. Like yours, the output includes the ACAD entities, but I don’t know how to change the ACAD entities to Dynamo objects.
Load the Python Standard and DesignScript Libraries
import sys
import clr
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
adoc = Application.DocumentManager.MdiActiveDocument
ed = adoc.Editor
def select_objects():
global adoc
global ed
output = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
acSSPrompt = ed.GetSelection()
if acSSPrompt.Status == PromptStatus.OK:
acSSet = acSSPrompt.Value
for s in acSSet:
if s:
obj = t.GetObject(s.ObjectId, OpenMode.ForRead)
output.append(obj)
t.Commit()
return output
OUT = select_objects()
It would be great if we can set nodes to a no-cache setting in a future release of Dynamo. The example above proves there is need for non-cachable nodes.
FYI…If you do now want to use the separate select object from handle node from the toolkit, I figured out how to do this with just the python script.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AutoCADNodes')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# Import references from Dynamo
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
adoc = Application.DocumentManager.MdiActiveDocument
ed = adoc.Editor
def select_objects():
global adoc
global ed
output = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
acSSPrompt = ed.GetSelection()
if acSSPrompt.Status == PromptStatus.OK:
acSSet = acSSPrompt.Value
hndl = []
for s in acSSet:
if s:
obj = t.GetObject(s.ObjectId, OpenMode.ForRead)
hndl.append(str(obj.Handle))
t.Commit()
for h in hndl:
output.append(SelectionByQuery.GetObjectByObjectHandle(h))
return output
if IN[0] == True:
OUT = select_objects()
else:
OUT = "nothing"
I have been trying to add selection filtering to this, but I can’t figure out how to convert this C# TypedValue array creation to python.
#Create a TypedValue array to define the filter criteria
TypedValue[] acTypValAr = new TypedValue[1];
acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "CIRCLE"), 0);
As a workaround, I’ve been filtering the selection downstream using the object DxfName. That works fine, but I think it would be more efficient to use the filtering capabilities of the selection set.
Hello @keith.sowinski AND @zachri.jensen
Is it possible to solve the problem that appeared in the filter?
Thank you so much
# Load the Python Standard and DesignScript Libraries
import sys
import clr
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AutoCADNodes')
from System import Array
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# Import references from Dynamo
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
adoc = Application.DocumentManager.MdiActiveDocument
ed = adoc.Editor
def select_objects():
global adoc
global ed
outputQ = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
#acSSPrompt = ed.GetSelection()
tv = TypedValue(0, "POLYLINE")
tva = Array[TypedValue]([tv])
acSSPrompt = ed.GetSelection(tva)
if acSSPrompt.Status == PromptStatus.OK:
acSSet = acSSPrompt.Value
hndl = []
for s in acSSet:
if s:
obj = t.GetObject(s.ObjectId, OpenMode.ForRead)
hndl.append(str(obj.Handle))
t.Commit()
for h in hndl:
outputQ.append(SelectionByQuery.GetObjectByObjectHandle(h))
return outputQ
OUT = select_objects()
#if IN[0] == True:
#OUT = select_objects()
#else:
#OUT = "nothing"