‘StationOffsetElevationToXYZ’ is ambiguous because…

'StationOffsetElevationToXYZ'
is ambiguous because multiple kinds of members with this name exist in class
'Autodesk.Civil.DatabaseServices.BaseBaseline'

 

StationOffsetElevationToXYZ_Issue

This issue
seems to be specific to VB.NET project (if you are using C# .NET, it works fine).

We have
noticed this in Civil 3D 2014 release and by the time we address this issue in
Civil 3D .NET API, here is a workaround with Reflection and .NET Extensions which you can
adopt to overcome this –

 

Public Sub TestCommand()
    Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
    Dim civilDoc As CivilDocument = CivilApplication.ActiveDocument
 
    If (civilDoc.CorridorCollection.Count = 0) Then Exit Sub
 
    Using trans As Transaction = db.TransactionManager.StartOpenCloseTransaction
      Dim corr As Corridor = trans.GetObject(civilDoc.CorridorCollection.Item(0), OpenMode.ForRead)
      Dim bl As Baseline = corr.Baselines.Item(0)
 
      Dim soe As Point3d = New Point3d(bl.StartStation, 0, 0)
      Dim pointAtSOE As Point3d = bl.StationOffsetElevationToXYZ(soe)
    End Using
  End Sub

 

<<<  

And declare a
VB.NET Module as below: 

>> 

Public Module Utility
   _
  Public Function StationOffsetElevationToXYZ(bl As Baseline, soe As Point3d) As Point3d
    Dim args As Object = {CType(soe, Object)}
    Dim argsModifiers As New System.Reflection.ParameterModifier(1)
    ' dont pass by reference, which is the new override for this method
    argsModifiers(0) = False
    Dim mods() As System.Reflection.ParameterModifier = {argsModifiers}
 
    ' Invoke the method late bound.
    Return bl.GetType().InvokeMember("StationOffsetElevationToXYZ", _
                                     System.Reflection.BindingFlags.InvokeMethod, _
                                     Nothing, bl, args, mods, Nothing, Nothing)
  End Function
End Module

 


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading