Offset alignment widening API use in python script

Hey!
I’m a beginner in Python and Civil 3D API.
I managed to create a code that adds widening to an offset alignment with given
parameters. That works as intended. I want to add an option to change TransitionType, but I get the following errors depending on using brackets or parentheses:

This is the code:

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

def addwidening(alignment):
	
	global adoc
	
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				id = alignment.InternalObjectId;
				alignid = t.GetObject(id, OpenMode.ForWrite, True);
				oInfo = alignid.OffsetAlignmentInfo;
				oInfo.AddWidening(100, 400, 10);
				r = oInfo.Regions[1];
				rent = r.EntryTransition;
				rent.TransitionType[2];
				entrydesc = r.EntryTransition.TransitionDescription;
				entrydesc.Length = 50;
				rext = r.ExitTransition;
				#rext.TransitionType(2);
				exitdesc = r.ExitTransition.TransitionDescription;
				exitdesc.Length = 50;
				t.Commit();
	return rent
	      		
# Assign your output to the OUT variable.
OUT = addwidening(IN[0])

What is the proper way to set that value?
Thanks in advance.

1 Like

Hi @kovacsv,

The TransitionType is an enumeration so you can’t use a subscript. Try this:

rent.TransitionType = Autodesk.Civil.TransitionType.CurveLineCurve

Hi @mzjensen,
Thanks, I also tried this way, but I got the following :frowning:
image

Ah OK. Up near the top of your code can you add
from Autodesk.Civil import *
and then change the line in the last post to
rent.TransitionType = TransitionType.CurveLineCurve

1 Like

Well, that worked. I thought it was something like this, but couldn’t figure it out.
Thank you.

1 Like