Thanks @Assem.Daaboul for the code.
Have updated the code to Create offset alignment and add a widening to it between the start and end station. An attempt to understand the code and combine it from the one of the post to add widening code. Suggestions and guidance are welcome for improvement.
"# 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’)
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 import *
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]
alignmentstyle = IN[1]
offset = IN[2]
startstation = IN[3]
endstation = IN[4]
result =
def cmoalignments(align,alignmentstyle,offset):
global adoc
global editor
global civdoc
try:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
alignmentId = align.InternalObjectId
al = t.GetObject(alignmentId, OpenMode.ForRead)
alname = al.Name
bbsz = "TEST1"
jbsz = "JBSZ"
lso = offset * -1
# for ease of code reading
# Left offset Alignment
leftoffsetalname = alname + "-" + bbsz
leftoffsetId = Alignment.CreateOffsetAlignment(db,leftoffsetalname,alname,lso,alignmentstyle,startstation,endstation)
alignid = t.GetObject(leftoffsetId, OpenMode.ForWrite, True);
oInfo = alignid.OffsetAlignmentInfo;
oInfo.AddWidening(110, 165, 4.6);
r = oInfo.Regions[1];
rent = r.EntryTransition;
rent.TransitionType = TransitionType.Linear;
entrydesc = r.EntryTransition.TransitionDescription;
entrydesc.Length = 25;
rext = r.ExitTransition;
#rext.TransitionType(2);
exitdesc = r.ExitTransition.TransitionDescription;
exitdesc.Length = 45;
result.append(leftoffsetalname)
t.Commit()
except Exception() as ex:
result.append(ex.message)
return result
Assign your output to the OUT variable.
OUT = cmoalignments(align,alignmentstyle,offset)"