algorithmic modeling for Rhino
Hello
I am fairly new to using C#. I have been using examples to create a GH component that uses Matlab code to evaluation. I manage to do this using items as inputs, but I want to use Lists as input. I am currently stuck when retreiving the data. I use the "GetDataList" command but I get the following error.
Any help is greatly appreciated
Tags:
the problem is that the second argument to GetDataList has to be a List<T> which MWNumericArray presumably is not. You might need to retrieve a List<double> first (depending on the type of the param you're harvesting from) and then turn it into a MWNumericArray afterwards. Also, with GetDataList you do not need to use the "ref" keyword. So it should look like this:
List<double> i1 = new List<double>();
if(!DA.GetDataList(0, i1)) return;
OK thank you for the help! :)
Here's a reference to the various ways of constructing an MWNumericArray: https://www.mathworks.com/help/dotnetbuilder/MWArrayAPI/html/T_Math...
There's some complexity as MWNumericArray appears to be able to support multi-dimensional arrays. I would maybe start here: https://www.mathworks.com/help/dotnetbuilder/MWArrayAPI/html/M_Math... and supply 1 for the row count and N for the column count where N is the number of items in your list. Then call ToArray() on your List<Double> and pass it as the realData argument. Not knowing anything about matlab or what you're trying to do, this is nothing more than a guess!
Great! I will look into it. Thank you for the help
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
© 2024 Created by Scott Davidson. Powered by