I want to implement the functionality shown in the figure using Python, but I get an error, and I don’t know how to solve it.
ss2 = Autodesk.Civil.DynamoNodes.ObjectByName("TinSurface","面组2530")
I want to implement the functionality shown in the figure using Python, but I get an error, and I don’t know how to solve it.
ss2 = Autodesk.Civil.DynamoNodes.ObjectByName("TinSurface","面组2530")
Hi,
try this
# 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 *
clr.AddReference('AutoCADNodes')
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
ss2 = SelectionByQuery.ObjectOfTypeByName("TinSurface","面组2530")
OUT = ss2
This is amazing; although I couldn’t find the entity node of SelectionByQuery.ObjectOfTypeByName here, I was still able to call it successfully in Python. If possible, could you tell me how to learn about such hidden functions?
you can explore an assembly :
Using Visual Studio (or others) by loading the dll
Using Fuget website
Autodesk.AutoCAD.DynamoNodes.SelectionByQuery - FuGet Gallery
Using the dir() method on Python objects
import sys
import clr
clr.AddReference("System.Reflection")
from System.Reflection import BindingFlags
# 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 *
clr.AddReference('AutoCADNodes')
import Autodesk.AutoCAD.DynamoNodes as aDynNodes
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
#name_spaces = aDynNodes.GetTypes()
OUT = dir(aDynNodes), dir(aDynNodes.SelectionByQuery), aDynNodes.SelectionByQuery.ObjectOfTypeByName.__doc__
Thank you very much for your help!