Back in the day (as python and dynamo newbie, so it is messy) I was experimenting with this without succes.
I remember it ran without warnings, but it did not set the profiles as it should have, and it made the profile views buggy as well. All show label ticks disappeared for some reason, thus the show label part in the code, but after the first run the views got buddy and the labels always disappeared. So here’s that code, but use it at your own risk:
# 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 *
from Autodesk.Civil 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
civdoc = CivilApplication.ActiveDocument
def switch_bandset(pv,bandset,n,pp,sp):
global adoc
# Get the active document in the AutoCAD session:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
#band set
if bandset == 1:
bs = civdoc.Styles.ProfileViewBandSetStyles["UNI_hsz_F&L_út+geotech"]
elif bandset == 2:
bs = civdoc.Styles.ProfileViewBandSetStyles["UNI_D_hsz"]
elif bandset == 3:
bs = civdoc.Styles.ProfileViewBandSetStyles["UNI_hsz_F&L_út+víz+geotech"]
elif bandset == 4:
bs = civdoc.Styles.ProfileViewBandSetStyles["UNI_hsz_F&LL_út+víz2+geotech"]
else:
print("Nincs ilyen típus")
for i in range(0,n):
# Get profileview id
pvId = pv[i].InternalObjectId
# Get profileID Proposed
ppId = pp[i].InternalObjectId
# Get profileID Surface
spId = sp[i].InternalObjectId
# Open Profileview
pvo = pvId.GetObject(OpenMode.ForWrite)
# Open and import Bands
pvbs = pvo.Bands
pvbs.ImportBandSetStyle(bs)
# Set BandItem properties
pvbsi = pvbs.GetBottomBandItems()
pvtsi = pvbs.GetTopBandItems()
pvbsc = pvbsi.Count
pvbscc = pvbsc-1
for k in range(0,pvbscc):
pvbsii = pvbsi.Item[k]
pvbsii.ShowLabels = True
pvbsipr = pvbsi.Item [0]
pvbsipr.Profile1Id = ppId
pvbsiex = pvbsi.Item [1]
pvbsiex.Profile1Id = spId
pvbsi = pvbs.GetBottomBandItems()
pvtsi = pvbs.GetTopBandItems()
t.Commit()
return pvtsi
pv = IN[0]
bandset = IN[1]
n = IN[2]
pp = IN[3]
sp = IN[4]
OUT = switch_bandset(pv,bandset,n,pp,sp)