Superelevation to Offset profile

Is there a way to get the superelevation data and translate that to an offset alignment profile cross slope regions?

I already have the stations and the crossslopes.

Hi @engenharia04NEFVB,

I haven’t seen a node out there to do this, so you’d need to make one yourself with Python or C#. The relevant classes would be Profile.OffsetProfileParameters and Profile.OffsetProfileParametersStation. There are settable properties for the station and slope.

I tried to do that, but I know little of python and API, but found this class you said.

https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=d9005f8a-b288-254d-0402-497b6eaa7fe5

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.


image

5 Likes

Thank you kovacsv. I would never be able to do that alone.

2 Likes