Create Offset Alignment dynamo civil
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
civdoc = CivilApplication.ActiveDocument
align = IN[0]
alignmentstyle = IN[1]
offset = IN[2]
offsetprofilestyle = IN[3]
slope = IN[4]
result = []
def cmoalignments(align,alignmentstyle,offset,offsetprofilestyle,slope):
global adoc
global editor
global civdoc
try:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
slopepercent = slope/100
n = align.Count
for i in range(0,n):
# get parent alignments to offset
alignment = align[i]
alignmentId = alignment.InternalObjectId
al = t.GetObject(alignmentId, OpenMode.ForRead)
alname = al.Name
# offset alignment name suffix and side variables
bbsz = "BBSZ"
jbsz = "JBSZ"
lso = offset * -1
rso = offset * 1
# get parent profile
profileId = al.GetProfileIds()[0]
profile = t.GetObject(profileId, OpenMode.ForWrite)
profilename = profile.Name
# Left offset Alignment
leftoffsetalname = alname + " " + bbsz
leftoffsetId = al.CreateOffsetAlignment(lso)
leftoffsetal = t.GetObject(leftoffsetId, OpenMode.ForWrite)
leftoffsetal.Name = leftoffsetalname
leftoffsetal.StyleName = alignmentstyle
result.append(leftoffsetalname)
# Left offset Alignment Profile
loprofile = profile.CreateOffsetProfileBySlope(leftoffsetalname,leftoffsetalname,offsetprofilestyle,slopepercent)
# Right Offset Alignment
rightoffsetalname = alname + " " + jbsz
rightoffsetId = al.CreateOffsetAlignment(rso)
rightoffsetal = t.GetObject(rightoffsetId, OpenMode.ForWrite)
rightoffsetal.Name = rightoffsetalname
rightoffsetal.StyleName = alignmentstyle
result.append(rightoffsetalname)
# Right offset Alignment Profile
roprofile = profile.CreateOffsetProfileBySlope(rightoffsetalname,rightoffsetalname,offsetprofilestyle,slopepercent)
t.Commit()
except Exception() as ex:
result.append(ex.message)
return result
# Assign your output to the OUT variable.
OUT = cmoalignments(align,alignmentstyle,offset,offsetprofilestyle,slope)