Hi,
You can try this in a Python Script node:
# 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')
clr.AddReference('Civil3DNodes')
clr.AddReference('System')
from System.Collections.Generic import List
# 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 *
# Import references for Dynamo for Civil 3D
from Autodesk.Civil.DynamoNodes import Alignment as DynAlignment
# 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
align = IN[0]
station = IN[1]
slope = IN[2]
result = []
oppsset = []
def offsetsuper(align,station,slope):
global adoc
global editor
global civdoc
try:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
#Selected alignment ID and object
alignment = align
alignmentId = alignment.InternalObjectId
al = t.GetObject(alignmentId, OpenMode.ForRead)
alname = al.Name
#Profile ID and object
profileId = al.GetProfileIds()[0]
profile = t.GetObject(profileId, OpenMode.ForWrite)
profilename = profile.Name
#get and clear existing parameters
opp = profile.OffsetProfileParameters(profile)
oppstations = opp.Stations
oppstations.Clear()
n = station.Count
for i in range(0,n):
slopepercent = slope[i]*0.01
opps = profile.OffsetProfileParametersStation(station[i],slopepercent)
oppsset.append(opps)
oppssetlist = List[Profile.OffsetProfileParametersStation](oppsset)
opp.Stations = oppssetlist
oppstations = opp.Stations
#a = opp.Stations
t.Commit()
except Exception() as ex:
oppstations.append(ex.message)
return oppstations
# Assign your output to the OUT variable.
OUT = offsetsuper(align,station,slope)
It is far from finished, it gets buggy after multiple runs on the same alignment, although it supposedly deletes the parameters first, so use at own risk. On first run, works as intended. You can use superelevation data as input lists.
