Create Alignment offset

Create Alignment offset

Anonymous
Not applicable
723 Views
2 Replies
Message 1 of 3

Create Alignment offset

Anonymous
Not applicable

Hi,

 

I am creating an alignment offset for all alignments in my drawing (See the code below), however i am getting this warning message

Warning 1 'Public Function CreateOffsetAlignment(offsetDistance As Double) As Autodesk.AutoCAD.DatabaseServices.ObjectId' is obsolete: 'Use static method Autodesk.Civil.Land.DatabaseServices.Alignment.CreateOffsetAlignment(...) instead." and there is no output when i run the program

 

Here is the code

 

PublicSubT10()

 

' This Program is to create alignment offset

Dim mydoc AsDocument = Application.DocumentManager.MdiActiveDocument

 

Dim mytrans AsTransaction= mydoc.TransactionManager.StartTransaction

 

Dim mycivil AsCivilDocument = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument

 

Dim ed AsEditor = Application.DocumentManager.MdiActiveDocument.Editor()

Dim alignments AsObjectIdCollection= mycivil.GetAlignmentIds

 Dim i AsInteger= 0

Dim x AsDouble = InputBox("Please Enter alignment offset value")

 

Try

 

For i = 0 Toalignments.Count - 1

 Dim a1 AsAlignment = mytrans.GetObject(alignments(i), OpenMode.ForRead)

Dim a2 AsObjectId= a1.CreateOffsetAlignment(10)

 

Next

 

Catch ex AsSystemException

MsgBox(ex.Message)

If mytrans IsNotNothingThenmytrans.Abort()

 

Finally

MsgBox("This is done By Tamer Mourad")

 If mytrans IsNotNothingThenmytrans.Dispose()

 

EndTry

EndSub

 

Regards,

 

Tamer Mourad

0 Likes
Accepted solutions (1)
724 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

>> warning message

I have not looked behind the warning, it means that the method/function may not be supported in one of the next releases of the API. So it should run normal without any errors at the moment.

I don't see what you "imported" and so in what Namespace you are using currently the .CreateOffsetAlignment. You can check that by yourselves ==> right click on this function ==> objectbrowser

 

>> and there is no output when i run the program

I'm missing the .Commit for the transaction, so nothing will be written back to the database.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks it worked

i missed the commit

0 Likes