RoboDK Forum
C++ AddShape expects Mat(4x4) as vertices (3xN)- 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++ AddShape expects Mat(4x4) as vertices (3xN) (/Thread-C-AddShape-expects-Mat-4x4-as-vertices-3xN)



C++ AddShape expects Mat(4x4) as vertices (3xN)-mFarzanehkaloorazi-07-30-2019

Hi,

I could get this to work with Python, but as far as I understood, in C++ something is wrong.

Look at AddShape API:

Quote: Item RoboDK:: AddShape(Mat*trianglePoints,Item*addTo,boolshapeOverride,Color*color)
trianglePoints=Listofverticesgroupedbytriangles(3xNor6xNmatrix,Nmustbemultipleof3becauseverticesmustbestackedbygroupsof3)


However, Mat is only a 4x4 matrix class!

Quote: classROBODKMat:publicQMatrix4x4

How can I use AddShape in C++? What type of value do I need to pass in?


RE: C++ AddShape expects Mat(4x4) as vertices (3xN)-Albert-08-19-2019

This issue has been fixed with the latest version of RoboDK and the plugin interface here:
https://github.com/RoboDK/Plug-In-Interface

You should use the tMatrix2D type to provide your shapes to RoboDK.


RE: C++ AddShape expects Mat(4x4) as vertices (3xN)-mFarzanehkaloorazi-09-20-2019

(08-19-2019, 11:11 PM)Albert Wrote:This issue has been fixed with the latest version of RoboDK and the plugin interface here:
https://github.com/RoboDK/Plug-In-Interface

You should use the tMatrix2D type to provide your shapes to RoboDK.

Hi Albert,

Thank you for your answer.

Would it be possible to fix this in RoboDK_api.ccp/h ?

I am not using plugins and want to use the API. I checked on Github and it is still the same as before atRoboDK-API/C++/robodk_api.cpp。

Basically I want to get something as simple as following to work:

Code:
# include“robodk_api.h”

int main(int argc, char *argv[])
{

RoboDK_API::RoboDK *RDK1 = NULL;
RDK1 = new RoboDK_API::RoboDK("",-1);

RoboDK_API::Item *partReference;
partReference = new RoboDK_API::Item(RDK1->getItem("Frame 1"));

double a[]={10,2,3,50,60,70,800,999,888};
RoboDK_API::tMatrix2D *mat2d = RoboDK_API::Matrix2D_Create();
Matrix2D_Set_Size(mat2d, 3, 3);
mat2d->data = a;

RoboDK_API::Color color; color.a = 1; color.g = 1; color.b = 1; color.r = 1;

RoboDK_API::Item body = RDK1->AddShape(mat2d, partReference, false, &color);

RDK1->CloseRoboDK();

return 0;
}



RE: C++ AddShape expects Mat(4x4) as vertices (3xN)-Albert-09-24-2019

I just realized that you were talking about the C++ API and not the C++ plugin interface. This is now solved and possible with both. The latest version of the RoboDK API for C++ is available here.:
https://github.com/RoboDK/RoboDK-API/tree/master/C++

I tested the sample you provided and it works.