Hi …
This python sript is working in Dynamo. it is doing a WP selection by points from a selected object (AutoCAD generic Curve). The resulting selection of CAD objects is available in Dynamo. How do I make that selection be the active selection the CAD session (active drawing)? I expected editor.SelectWindowPolygon … with the points … to be a selection in the CAD sessions … in the Properties palette … but its not … it’s “silent” not doing anything/ no using the result of the Dynamo selection … ?
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 *
apc = Point3dCollection()
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
seg = Application.GetSystemVariable("VIEWSIZE") * 0.02
ge = editor.GetEntity('\nSelect boundary polyline for WP selection: ')
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
e = t.GetObject(ge.ObjectId,OpenMode.ForRead)
if isinstance(e, Curve):
a = e.Length
d = 0
while d < e.Length:
p = e.GetPointAtDist(d)
apc.Add(p)
d = d + seg
t.Commit()
selset = editor.SelectWindowPolygon(apc)
OUT = selset