Set a negative Elevation value using ProfilePVI::Elevation

By Partha Sarkar

AutoCAD Civil 3D .NET API ProfilePVI.Elevation allows us to get or set the elevation value of the PVI. There was some issue around setting a negative elevation value using ProfilePVI.Elevation API in Civil 3D 2012 and the same is addressed now in Civil 3D 2013 .NET API.

Here is a VB.NET code snippet which demonstrates how to set a negative elevation value to a PVI object in AutoCAD Civil 3D 2013:

Using (trans)
    ' Select the Profile
    Dim promptEntOp As New PromptEntityOptions(vbCrLf + "Select a Profile : ")
    Dim promptEntRs As PromptEntityResult
    promptEntRs = ed.GetEntity(promptEntOp)
    If promptEntRs.Status  PromptStatus.OK Then
        ed.WriteMessage("Exiting! Try Again !")
        Exit Sub
    End If
    Dim idEnt As ObjectId = promptEntRs.ObjectId
 
    '' Get the Profile object
    Dim profile As Profile = trans.GetObject(idEnt, OpenMode.ForRead)
    Dim o_PVI As ProfilePVI = profile.PVIs.Item(1)
 
    ed.WriteMessage(vbCrLf + "PVI Station : " + o_PVI.Station.ToString() + "   " + "PVI Elevation : " + o_PVI.Elevation.ToString())
 
    ' Try chnaging the PVI Elevation value now 
    Try                
        o_PVI.Elevation = -3.0 '' This value is specific to a test DWG file 
        ed.WriteMessage(vbCrLf + "PVI Elevation after Change  : " + o_PVI.Elevation.ToString())
 
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, )
      Exit Sub
    End Try
End Using

Comments

2 responses to “Set a negative Elevation value using ProfilePVI::Elevation”

  1. TyroneK Avatar
    TyroneK

    My thanks to the C3D crew for fixing this. Could you share with us why this was broken prior to 2013?

  2. Partha Avatar
    Partha

    Glad to know that you are happy about it now :)
    Somehow it slipped through the cracks in previous release. Got it fixed now.
    Thanks,
    Partha

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading