algorithmic modeling for Rhino
Hi everybody,
I am starting to work with grasshopper python component to send information to analysis software and to get back results.
The sending and analysing works well. The problems come when I try to get the output. In this case the output needs to be set before requesting for it. I am doing it with this call:
ret = gsaobj.Output_Init_Arr(1,"Global","A1",14003001,3)
In API help the call is documented like this:
short Output_Init_Arr (long iFlags, string sAxis, string sCase, enum ResHeader header, long num1dpos)
so this call has 5 arguments (long, string, string, long, long) (the enums are defined as longs)
This call works, because when I print the ret, i get 0 that is "succeded" so everything works so far.
Then I request the output with the following:
results = []
ret = gsaobj.Output_Extract_Arr(10,results,numcomponents)
In API help the call is documented like this:
short Output_Extract_Arr(long iRef, SAFEARRAY(struct GsaResults)*arrayResults, long* numComponents)
I am getting the error "
Runtime error (ArgumentException): Could not convert argument 1 for call to Output_Extract_Arr."
So it seems that is not accepting 10 as a long in the beginning (assuming that argument 1 is the first). I already tried passing a variable as long, using long(10) there, nothing works.
Furthermore I don't know if the other two variables are correct like that. I come from VBA where I need to declare everything but AFAIK python is more permissive in this sense. "results" should be a dynamic array of objects and "numcomponents" a long.
Any help would be appreciated!
Thanks! :)
Tags:
Hi Stefano
I think argument 1 might actually be the SAFEARRAY(struct GsaResults)*.
It would help if you had an example of a working call in IronPython or any other .Net language. That way, I could possibly think of a parallel Python solution.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Hi Giulio,
thanks for your reply.
In the end I wrote the whole code using VB scripting component and it works flawlessly.
What I am using is the following:
Dim ResultArray() As interop.gsa_8_7.GsaResults: resultarray = Nothing
Dim NumComponents As Long
ret = GSA.Output_Extract_Arr(10, ResultArray, NumComponents)
These API calls might be a bit "strict" for object types. I don't know exactly How python works, but I would prefer passing to functions objects of a known type. Is this possible?
Thanks again!
C# and Vb.Net are types languages, while Python is dynamic, so you don't specify types. However, it looks like possibly ResultArray could be specified as ResultArray = None in Python. That is how you are declaring it in Vb.Net.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by