Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

C++ AddShape expects Mat(4x4) as vertices (3xN)

#1
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, bool shapeOverride, Color *color)
trianglePoints =List of vertices grouped by triangles (3xN or 6xN matrix, N must be multiple of 3 because vertices must be stacked by groups of 3)


However, Mat is only a 4x4 matrix class!

Quote:class ROBODK Mat : public QMatrix4x4 

How can I use AddShape in C++? What type of value do I need to pass in?
#2
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.
#3
(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 at RoboDK-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;
}
#4
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.
  




Users browsing this thread:
1 Guest(s)