• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    AutoCAD Civil 3D Customization

    Reply
    Active Contributor
    Posts: 32
    Registered: ‎09-12-2006
    Accepted Solution

    Create Alignment offset

    151 Views, 2 Replies
    10-24-2011 12:36 AM

    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

    Please use plain text.
    *Expert Elite*
    Posts: 6,460
    Registered: ‎06-29-2007

    Re: Create Alignment offset

    10-24-2011 08:08 AM in reply to: tahmad

    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
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    Posts: 32
    Registered: ‎09-12-2006

    Re: Create Alignment offset

    10-24-2011 09:19 AM in reply to: alfred.neswadba

    Thanks it worked

    i missed the commit

    Please use plain text.