Select multiple

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"

(IN[0] is just a bool to run the script or not)

8 Likes