Model space Selection Area

While I’m still trying to get up to speed with Dynamo for C3D, I do want to ask this, is there a node that will allow me to select items within a selection area (point series)? I want to be able to figure this out, but I’m not sure where to start. All I need at the moment is a direction to pursue. I’ve looked through the nodes in 26.1, civil nodes, and camber. I haven’t found what I’m looking for, but I might have simply over looked the node if it exists.

Thanks!

Hi @UBDesign,

Do you mean the Select Objects node? Or do you want to input a list of Dynamo points to define the selection boundary?

What is really want is to be able to use a Parcel to outline an area and select the objects (hatches, polylines, other parcels, ect.) like I would with a selection window so that I can retrieve data from the selected objects.

Got it. Currently we don’t have any nodes to do a spatial query like that (i.e., objects within some boundary). You can sometimes do a workaround where you get the boundary geometry you want into Dynamo as a polycurve, patch it with a surface, and then check to see which objects intersect that surface. But that isn’t a bulletproof approach, and becomes tricky very quickly to try and determine full containment or only partial containment.

2 Likes

I think I have some sample Python to extract objects within the boundary formed by the XY components of another object which might help here, however I haven’t worked with it on parcels or any other Civil3D object before so it might not function entirely.

@UBDesign can you post a sample model?

I have also used object.Location, point.PullOntoPlane, and Geometry.DistanceTo grab all objects within a planar distance to a selected object.

Zach,

Thanks for the response. Helps me to know that I can stop looking through the nodes at this point to find what I’m looking for. So then two nodes that I’m excited to see on the future deployments is one for this type of selection area and the project to profiles. :grin: Thank you for all of your help making Dynamo what it is at this point. In the near future I might start looking into node creation.

I’m currently at the front end of this graph idea, but I will put together a sample dwg to show you want I’m looking to accomplish.

1 Like

real easy if you are using spatial entities (map3d) within Civil3D

not so easy with AutoCAD or C3D entities

The functions in C3D are extremely basic:

you would just have a query [LOCATION:INSIDE.POLYGON.ID1]

If the datasource was a proper spatial database, you’d have queries with functions like st_within, st_intersects, st_contains, and present the query in C3D

in your case- the query would be something like “work out which parcels all these objects are within”

1 Like

Not entirely sure, but I think this is what you’re after:
select by object

Haven’t tried with civil 3D objects, but it seems like it should work, and looks like what I think you’re after.

The Python code
########################################
############## Properties ##############
########################################
__author__ = 'Jacob Small'
__version__ = '0.1.0'
__description__ = "Select objects from the ACAD instance's active editor, using the provided closed polygon and a boolean input to control crossing status."
__DynamoBuilds__ = "3.3"
__ReleaseNotes__ = "POC Only, not for production use."
__Dependancies__ = "None"
__Copyright__ = "2025, Autodesk Inc."
__license__ = "Apache 2.0"



########################################
### Configure the Python environment ###
########################################
# standard imports
import sys #import sys so we can workw ith teh Python engine
import clr #import the common langauge runtime (clr) so we canw ork with .NET objects
# Add Assemblies for AutoCAD
clr.AddReference('AcMgd') #add the managed autocad environment library to the CLR
clr.AddReference('AcCoreMgd') #add the managed autocad core library to the CLR
clr.AddReference('AcDbMgd') #add the managed autocad database library to the CLR

# Import references from AutoCAD
from Autodesk.AutoCAD.ApplicationServices import * #import the AutoCAD application services to the Python environment 
from Autodesk.AutoCAD.Geometry import Point3dCollection, Point3d #import the Point3d and Point3dCollection classes to the Python environment

#add the Dynamo geometry library
clr.AddReference('ProtoGeometry') #add the Dynamo geometry library to the CLR
from Autodesk.DesignScript import Geometry as DG #add the Dynamo geometry library to the Python environment as DG so we don't have conflics with ACAD classes

# Import refernces from the Dynamo for Civil 3D library
clr.AddReference('AutoCADNodes')
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery #import the Dynamo for Civil 3D selection by query class to the Python environment
from Autodesk.AutoCAD.DynamoNodes import  Document as DynAcadDoc #import the Dynamo for Civil 3D document class as DynAcadDoc to prevent namespace collision



#########################################
###### Global variables and inputs ######
#########################################
geo = IN[0] #geometry object to select with
if not geo.__class__ == DG.PolyCurve: #if the input is not a polycurve
    sys.exit("\r\n\r\nThe provided geometry much be a closed polycurve.\r\n\r\n") #throw a warning
if not geo.IsClosed: #if the input is not closed
    sys.exit("\r\n\r\nThe provided polycurve must be closed.\r\n\r\n") #throw a warning
crossing = IN[1] #boolean to control if crossing objects should be selected
editor = Application.DocumentManager.MdiActiveDocument.Editor #get the active docuemnt's editor



#########################################
############ Code goes here #############
#########################################
#build a Point3dCollection to drive the editor selection methods
pnts = geo.Points #extract the points from the geometry
points = Point3dCollection([Point3d(i.X,i.Y,i.Z) for i in pnts]) #create a Point3DCollection object
#build a selection set using crossing or window polygon methods, according to the crossing input
if crossing: #if crossing is true
    selectionSet = editor.SelectCrossingPolygon(points) #set the selection set using the crossing polygon method
else: #otherwise
    selectionSet = editor.SelectWindowPolygon(points) #set the selection set using the window polygon method
#convert the selection to a list of handles
selectionSet = selectionSet.Value.GetObjectIds() #get the object IDs from the selection set
selectionSet = [i.Handle for i in selectionSet] #get the handle from the object ids in the selection set
#get the selection as Dynamo wrapped objects so we can use them with Dynamo nodes
selection = [SelectionByQuery.ObjectByHandle(DynAcadDoc.Current, str(i)) for i in selectionSet] #select the objects as Dynamo wrapped ojects



#########################################
##### Return the results to Dynamo ######
#########################################
OUT = selection #return the selection to the Dynamo environment
3 Likes

Jacob, that it awesome! I will pull this into Dynamo and see if I can get it to work with C3D objects. I’ll probably get to this tomorrow afternoon and report back to you, to let you know what results I get.

1 Like