I have created a script that adds a vast number of targets to specific subasseblies in all regions. The addig part works fine with the C3D Toolkit nodes but I’m stuck with deleting the target list before adding the new one. I try to clear the ObjectIDCollection, but dynamo says there is no such attribute.
What am I missing here? Thanks.
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 *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
tinfo = IN[0]
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
# Place your code below
x = tinfo.TargetIds
x.Clear()
t.Commit()
The input object type is Autodesk.Civil.DynamoNodes.SubassemblyTargetInfo, so you’d have to have to get the underlying Autodesk.Civil.DatabaseServices.SubassemblyTargetInfo object via the transaction before any of the API members can be called.
Oh, okay thanks @mzjensen . That makes sense.
Although, I’m trying to get the Autodesk.Civil.DatabaseServices.SubassemblyTargetInfo object without success. I looked up some solution ideas on the forum, but none of them seem to work.
Tried InternalDBObject and InternalObjectID, but it says there are no such attributes.
I have also tried to figure it out from the toolkit dll, but I’m not qualified enough to understand the inheritance from there.
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
tinfo = IN[0]
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
# Place your code below
targetinfoId = tinfo.InternalObjectID
targetinfo = t.GetObject(targetinfoId, OpenMode.ForWrite)
t.Commit()
pass
# Assign your output to the OUT variable.
OUT = targetinfo
Sorry @kovacsv, I misread the steps you’ve taken so far. It looks like the SubassemblyTargetInfo class in the Toolkit doesn’t inherit from CivilObject (or ultimately ObjectBase), so that’s why the InternalObjectId property isn’t available. So I think your Python node will have to start with the Corridor as the input (since you can get its ObjectId) and then work your way down the class hierarchy to access the target info.