c# addCurve- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API) +--- Thread: c# addCurve (/Thread-c-addCurve) |
c# addCurve-cerver-08-06-2018 the addCurve Method in c# only takes a Mat type which is not a list but only a single position fro what i can see. in c# how would you pass it a list of points? RE: c# addCurve-Albert-08-14-2018 This code should show an example to convert an array of doubles to a Mat file that you can use for RoboDK.AddCurve() // Create the list of points as an array of array of doubles // The size is 4 points set as XYZijk. XYZ is the position and ijk is the tool Z axis (ijk is optional) const int np = 4; double[,] points_xyzijk = new double[np, 6] {{0,0,0, 0,0,1}, { 500, 0, 0, 0, 0, 1 }, { 500, 500, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 1 } }; // Convert a double array of arrays to a Mat object: Mat points_mat = new Mat(6, np); for (int c=0; c { for (int r=0; r<6; r++) { points_mat[r,c] = points_xyzijk[c,r]; } } / /加载垫在R文件oboDK RoboDK.Item object_curve = RDK.AddCurve(points_mat); // Rename the curve object object_curve.setName("Imported Curve"); More information here: //www.sinclairbody.com/doc/en/CsAPI/api/RoboDk.API.RoboDK.html#RoboDk_API_RoboDK_AddCurve_RoboDk_API_Mat_RoboDk_API_IItem_System_Boolean_RoboDk_API_Model_ProjectionType_ RE: c# addCurve-cerver-08-14-2018 perfect thanks that worked, its not the most intuitive way to create an object. here is the code as i edited in case its helps someone else out. i removed a loop and directly indexed the double[] for speed and clarity
Code:
public static Mat PointListToMat(Point[] pts, Vector ToolVec = null)
|