I’m trying to make use the python script option in dynamo in civil 3d to call some functions in a com object library written in C so that we can perform some bespoke calculations for creating drawing objects. I have managed to get the code I need to work in Spyder using python 3.6, however when I use this code in dynamo it does not work.
The com object loads fine and te function that I’m calling is as follows:
short GetNumber(short iStageIndex, short* sNumVal)
The return value of which indicates whether the call was successful or not and sNumVal is the number I’m interested in.
In Spyder (python 3.6) and the ref params are returned in a tuple such that it needs to be called as follows:
ret = GetNumber(0); success = ret sNumVal = ret
In Dynamo the above doesn’t appear to work anymore. The above call results in the following error:
StandardError: Error while invoking GetNumber
No tuple is returned so to get rid of this error I have to pass something in to the second parameter:
sNumVal = 0 ret = GetNumber(0, sNumVal)
trouble is sNumVal does not get set - do I need to do something to pass it by reference? I’ve tried googling this at length but have so far not found the answer.