Good Afternoon,
I have been fiddling with some alignment commands in the Inroads SS2 SDK and have had some trouble getting a list of alignment pointers from the scadSDK_cogoGetHorizontalAlignments. I have tried multiple things to use this including: using the function as written in the SDK, Modify the SDK function to take an array and modifiy this SDK funtion to take a string. None have worked. Here is my code.:
Sub Get_Alignment_List()
'scadSDK_cogoCountNumberOfHorizontals Lib "SCadSDKAT" (ByVal prj As Long) As Long'scadSDK_cogoGetHorizontalAlignments Lib "SCadSDKAT" (hAlg As Long, Count As Long, ByVal prj As Long) As LongDim oProj As LongDim oFlag As LongDim oCount As LongDim oALG As Long
oProj = 0
oCount = scadSDK_cogoCountNumberOfHorizontals(oProj) 'Gets the number of alignments in the project, needed as input.Debug.Print oProj 'Prints the value of oProj to see if it has changed (it doesn't)Debug.Print oCount 'Prints the number of Alignments in the active project.oFlag = scadSDK_cogoGetHorizontalAlignments(oALG, oCount, oProj)Debug.Print oALG ' print the alignement pointerEnd SubMy desire is to build a list of alignment names for a use to select from. I have a work sub to get then name of the active alignment so it should be simple to modify that once i get the alg pointer i need.Here is the SDK help file for the function.
#include <SCadCogo.h> int scadSDK_cogoGetHorizontalAlignments ( ALGalign **hAlgs, // (i/o) pre-allocated alignment list int *cnt, // (i/o) number of alignments in list ALGproject *prj // (i) geometry project );
hAlgs
NULL
prj
cnt
The term list confuses me. As a non-C programmer i don't understand how this type works. It seems to me that a list is an array but in other functions the return value of a list is a string type with individual characters separated by the ascii version of a null.Any help would be great.Thanks,Jason
Jason,
You need to pre-dimension an array of Longs of the correct size to hold the list returned from the scadSDK_cogoGetHorizontalAlignments. You then feed the first element of the array to the function.
Dim lAlignCount as Long Dim lProjectID as Long Dim lHorizAlignIDs() as Long 'Array of Longs 'Get number of horizontal alignments for a given project lAlignCount = scadSDK_cogoCountNumberOfHorizontals(ProjectID) 'Resize the array of Longs to be equal to the number of alignments. Zero based, hence the -1 ReDim lHorizAlignIDs(lAlignCount - 1) 'The InRoads DLL will populate your array of Longs with the ID's scadSDK_cogoGetHorizontalAlignments lHorizAlignIDs(0), lAlignCount, lProjectIDHope that helps. It took me a very long time to figure out how to work with the DLL calls.Brett
Answer Verified By: Jason Brame
Whoops, guess I don't know how to use the syntaxhighliter...
Dim lAlignCount as LongDim lProjectID as LongDim lHorizAlignIDs() as Long
lAlignCount = scadSDK_cogoCountNumberOfHorizontals(ProjectID)ReDim lHorizAlignIDs(lAlignCount - 1)scadSDK_cogoGetHorizontalAlignments lHorizAlignIDs(0), lAlignCount, lProjectID
It's one of those days...
Dim lAlignCount as Long Dim lProjectID as Long Dim lHorizAlignIDs() as Long 'Array of Longs 'Get number of horizontal alignments for a given project lAlignCount = scadSDK_cogoCountNumberOfHorizontals(ProjectID) 'Resize the array of Longs to be equal to the number of alignments. Zero based, hence the -1 ReDim lHorizAlignIDs(lAlignCount - 1) 'The InRoads DLL will populate your array of Longs with the ID's scadSDK_cogoGetHorizontalAlignments lHorizAlignIDs(0), lAlignCount, lProjectID
Unknown said: I don't know how to use the syntaxhighliter
When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:
Regards, Jon Summers LA Solutions