You are using a version without Ads of this website. Please, consider donating:

Greetings,

Having problem with multidimensional array for C++/CLI

 ``1234567891011121314`` ``````// Got a 2x3 array cli::array ^points = gcnew cli::array(2,3); // populate it points[0,0] = 10.0; points[0,1] = 20.0; points[0,2] = 30.0; points[1,0] = 100.0; points[1,1] = 200.0; points[1,2] = 300.0; // now here's my problem cli::array ^point = gcnew cli::array(3); point = point[0];``````

How can I access to copy the first array of a 2d array into a 1d array?

Help is always greatly appreciated!
What are u trying to do again? I can help but dont understand the question.
I'm kinda guessing at what you're after try this:
 ``1234`` ``````for(int i=0;i<3;i++)//point = point[0]; { point[i] = points[0,i]; }``````

 `` `` ``Vec3->Copy(cli::array ^src, cli::array ^dest);``

I have a cli::array<double,2> ^points, contains two 1d arrays of xyz coordinates, so for the function call I tried;

 ``12`` ``````cli::array ^point = gcnew cli::array(3); Vec3->Copy(points[0], point); // copying the first point coordinates to a 1d array ``````

This is copying the first index of 3 elements from a 2-dimensional array into a 1d array.

For native C++ version I would have done the following for the CAD API function prototype
UF_VEC3_copy(double src[], double dest[]).

 ``123`` ``````double points[2][3]; double point[3]; UF_VEC3_copy(points[0], point);``````

But I'm moving on to the Managed version of the CAD API.

Thanks again.
Not sure but pretty confident you can't use array:copy for multidimensional arrays. that's why i presented the loop. I'll post back.
Topic archived. No new replies allowed.