# Offset alignment widening API use in python script

**URL:** <https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216>\
**Category:** Civil 3D\
**Tags:** python, dynamo\
**Created:** [June 16, 2021, 9:43pm UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216 "2021-06-16T21:43:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [June 16, 2021, 9:43pm UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216/1 "2021-06-16T21:43:30Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/9/e9df568af34d6e049cadcf17b76eae28f82f4e32.png)

This is the code:

```auto
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.

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 17, 2021, 5:20am UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216/2 "2021-06-17T05:20:38Z")

</div>

Hi @kovacsv,

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

`rent.TransitionType = Autodesk.Civil.TransitionType.CurveLineCurve`

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [June 17, 2021, 7:02am UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216/3 "2021-06-17T07:02:00Z")

</div>

Hi @zachri.jensen,  
Thanks, I also tried this way, but I got the following ☹  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/3/53a44920bf21650ca9e69fba6129465b98090457.png)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 17, 2021, 1:17pm UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216/4 "2021-06-17T13:17:03Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [June 17, 2021, 4:31pm UTC](https://forum.dynamobim.com/t/offset-alignment-widening-api-use-in-python-script/65216/5 "2021-06-17T16:31:29Z")

</div>

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