I am trying to find out how to use the scadSDK_cogoStationEquationGetInfo sdk function for inroads. The SDK help tells me that the Station Equation is the input and the remaining variable are the output. How do i get the Station equation to put into the variable? I have tried using scadSDK_cogoGetActiveStationEquationBuffer to get the active the station equation buffer. When i use the value generated from the Equation Buffer the Get Info function does not cause a catostrophic failure. But I don't get any useful information about the station equations.
Another thing I read in the SDK Help was "Passing Null for any of the arguments will indicate to the function to ignore that argument." So I added seed values to the to all of my variables but when the variables are passed back the values are still the seed value.
The ALG file i am using to test my program is attached to this post.
Here are the equation functions i am using from the SDK.
Public Declare Function scadSDK_cogoGetActiveStationEquationBuffer Lib "SCadSDKAT" (seAlg As Long, ByVal hAlg As Long) As Long
Public Declare Function scadSDK_cogoStationEquationGetInfo Lib "SCadSDKAT" (ByVal bckEqn As String, ByVal ahdEqn As String, stn As Double, bck As Double, ahd As Double, x As Double, y As Double, ByVal ele As Long) As Long
Here is my code:
Sub TestInroads()
Dim oXY As Long, oHorizAlign As LongDim oStation As Double, oOffset As Double, oAzimuth As Double, oX As Double, oY As DoubleDim oBackSta As Double, oAheadSta As Double, oStationEq As DoubleDim oBack As String, oAhead As StringDim oPnt1 As DPoint3dDim oProject As Long, oAlg As LongDim oInroadsVar As LongDim i As Integer
If scadsdk_initalize = SDK_SUCCESS Then 'Check for inroads
'Creates Dpoint3d forStation and Offset Function, This point will eventually be assigned by an iPrimitiveCommandEvents Class Module.
'To simplify the Debugging I am starting with a set point that I know has an equation before it.
oPnt1.x = 2378849.3362oPnt1.y = 228083.788oPnt1.z = 0
'Fill in Seed Values
oX = 1oY = 1oAhead = "A"oBack = "B"oStationEq = 1oBackSta = 0oAheadSta = 0
oXY = scadSDK_cogoGetActiveProject(oProject) 'Get active Project oXY = scadSDK_cogoGetActiveHorizontalAlignment(oHorizAlign, oProject) 'Get active Horiz Alignment oXY = scadSDK_cogoXyToStationOffset(oStation, oOffset, oAzimuth, oHorizAlign, oPnt1) 'Get Station and Offset from oPnt1 XY
oXY = scadSDK_cogoGetActiveStationEquationBuffer(oAlg, oHorizAlign) 'Gets oAlg as a Long Integer (Equation Buffer) oXY = scadSDK_cogoStationEquationGetInfo(oBack, oAhead, oStationEq, oBackSta, oAheadSta, oX, oY, oAlg) 'oAlg is Input, All others are output Debug.Print oBack & " " & oAhead 'Prints final value of oBack and oAhead End If
End Sub
Thanks,
Jason
Here is some code I've used that works ok and should help you understand what is needed:
Private Sub GetStationEquations(hAlg As Long, station1 As Double, station2 As Double, ByRef lineArray() As String)
Dim backEqe As String
Dim aheadEqe As String
Dim thisStation As Double
Dim backStation As Double
Dim aheadStation As Double
Dim xx As Double
Dim yy As Double
Dim seAlg As Long
Dim sts As Long
Dim ele As Long
Dim numEles As Long
'set default metrage adjustment values
lineArray(3) = "FALSE"
lineArray(4) = "0.000"
lineArray(5) = "0.000"
lineArray(6) = "0.000"
sts = scadSDK_cogoGetActiveStationEquationBuffer(seAlg, hAlg)
If sts = SDK_SUCCESS Then
' get the number of elements available
numEles = scadSDK_cogoCountNumberOfElements(seAlg)
If numEles <> 0 Then
'loop through and get all ele types
ele = scadSDK_cogoElementFirst(seAlg)
While ele <> 0
backEqe = String$(ALGPNTSZ, vbNull)
aheadEqe = String$(ALGPNTSZ, vbNull)
sts = scadSDK_cogoStationEquationGetInfo(StrPtr(backEqe), StrPtr(aheadEqe), thisStation, backStation, aheadStation, xx, yy, ele)
Dim stnString As String, newStation As Double
stnString = ZTrim(backEqe) & " " & format(backStation, "#0.000")
sts = scadSDK_cogoStringToStation(hAlg, newStation, StrPtr(stnString))
If newStation >= station1 And newStation <= station2 Then
lineArray(3) = "TRUE"
lineArray(4) = backStation
lineArray(5) = aheadStation
lineArray(6) = format(backStation - aheadStation, "0.000000")
End If
ele = scadSDK_cogoElementNext(ele)
Wend
Paul,
Thanks for the Code. I have one question about it. What is the ZTrim function
Thanks
ZTrim is my poorly named function to remove null characters from a string :)
Public Function ZTrim(text As String) As String
Dim pos As Long
pos = InStr(text, vbNullChar)
If pos > 0 Then
ZTrim = Left$(text, pos - 1)
Else
ZTrim = text
End Function