I want to change the Breakline set name. Below code is what i have so far. I think i have the wrong object “Surface” instead of “TinSurface”. “TinSurface” class has a property “BreaklinesDefinition”. But i can’'t find how the get the “TinSurface” object, thats where the problem starts.
from ctypes import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
from Autodesk.Civil import *
adoc = Application.DocumentManager.MdiActiveDocument
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
surfId = surface.InternalObjectId
print("surfId:" + str(surfId))
surf = surfId.GetObject(OpenMode.ForWrite)
brkdefs = surf.BreaklinesDefinition
print("Count: " + str(brkdefs.Count)) **// It gives me a count**
#brkdefs[brkdefs.Count - 1].Description = "Test"
print("The process AddSurfaceDescription Completed")
print("The process AddSurfaceDescription failed")
return "The process failed"
OUT = AddSurfaceDescription(IN)
Need to change the descriptions for all of the breakline sets. I tried to do this is one python script but couldn’t get it working. I hope that the order of adding breaklines to a surface in different sets, will be same as reading the sets in a second script.
OK. Also, just to clarify…are you trying to change the descriptions for breakline sets that have already been created outside of your script? It’s only possible to set the description for an instance of a SurfaceOperationAddBreakline object, which can only be instantiated by creating/adding a new breakline set.
Database db = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
TinSurface tinSurface = trans.GetObject(surfaceId, OpenMode.ForWrite) as TinSurface;
for (int b = 0; b < tinSurface.BreaklinesDefinition.Count; b++)
SurfaceOperationAddBreakline operation = tinSurface.BreaklinesDefinition[b];
// the RemoveAt will act at this level
Based on what you describe, it sounds like you have an empty surface and are trying to add breaklines to the surface while including breakline descriptions in the surface definition. If that’s true, then this would be the workflow for Option 2:
Add feature lines as breaklines to a surface using TinSurfaceExtensions.AddStandardBreaklines (Civil 3D Toolkit package)
Remove the breaklines from the surface (Python)
Add the breaklines to the surface and set descriptions (Python)
Removing the breaklines (step 2) is necessary because…
So essentially you would be adding the breaklines, removing the breaklines, and then readding them again with descriptions. I think it would be more efficient to do Option 1, do you agree?
Here are the steps to do it in a Python node. This is just pseudocode, meaning it is only intended to show the general outline and will not work if copied and pasted.
dynamoSurf = IN
featureLines = IN
midOrdinateDist = IN
maxDist = IN
weedDist = IN
weedAngle = IN
desc = IN
# Unwrap the Dynamo surface object to get internal surface object
civilSurf = dynamoSurf.InternalDBObject
# Upgrade the object's OpenMode status so that it is write-enabled
# Get the collection of breakline definitions
brkLineDefs = civilSurf.BreaklinesDefinition
# Create an empty Object ID collection
oids = ObjectIdCollection()
# Loop through each feature line and collect the Object IDs
for fl in featureLines:
# Create new breakline definitions
brkLineSet = brkLineDefs.AddStandardBreaklines(oids, midOrdinateDist, maxDist, weedDist, weedAngle)
# Set breakline definition description
brkLineSet.Description = desc