# CreateOffsetAlignment using python:

**URL:** <https://forum.dynamobim.com/t/createoffsetalignment-using-python/103170>\
**Category:** Developers\
**Tags:** civil3d\
**Created:** [July 31, 2024, 4:21pm UTC](https://forum.dynamobim.com/t/createoffsetalignment-using-python/103170 "2024-07-31T16:21:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abr0197236](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@abr0197236](https://forum.dynamobim.com/u/abr0197236)\
**Post date:** [July 31, 2024, 4:21pm UTC](https://forum.dynamobim.com/t/createoffsetalignment-using-python/103170/1 "2024-07-31T16:21:17Z")

</div>

Hello,  
I am trying to create offset alignments. But I keep getting an error.  
can you please check my code?

**Script**

def CreateOffset():  
global adoc  
global editor  
global civdoc  
result =

```
with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            civildoc = CivilApplication.ActiveDocument
            Ids = civildoc.GetAlignmentIds()
            Alignments = []
            
            for id in Ids:
                al = t.GetObject(id, OpenMode.ForRead)
                Alignments.append(al.Name)
            
            if Alignments:
                # Take the first alignment for the demonstration
                first_alignment = Alignments[0]
                al = t.GetObject(Ids[0], OpenMode.ForRead) # Get the alignment object
                
                offset_name = "Subhi"
                offset_distance = 1
                right_offset_id = al.CreateOffsetAlignment(offset_distance)
                right_offset_al = t.GetObject(right_offset_id, OpenMode.ForWrite)
                right_offset_al.Name = offset_name
                right_offset_al.StyleName = "Offsets"
                result.append(offset_name)
            
            # Commit before end transaction
            t.Commit()
            
return result

```

# Assign your output to the OUT variable.

OUT = CreateOffset()

**Error** :

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/6/2692bd91fb444081ca2bd4f25130c434dd516d13.png)
