how to use user command in DLL

how to use user command in DLL

qiu_xiaohong
Not applicable
18 Views
5 Replies
Message 1 of 6

how to use user command in DLL

qiu_xiaohong
Not applicable

Image.html

"rotate" is a user command,how can i use it in DLL

Accepted solutions (1)
19 Views
5 Replies
Replies (5)
Message 2 of 6

mischa_spelt
Advisor
Advisor
Accepted solution

User commands are stored in the tree under MODEL:/Tools/UserCommands/rotate. Their code is stored in the first subnode which is usually called "code". 4508-usercommandintree.png

You can use the nodefunction command like you would normally to execute the user command, from the DLL:

treeonde rotateCommand = first(node("MODEL:/Tools/UserCommands/rotate"));
double result = nodefunction(rotateCommand, robot, Rot, order_number, table_name1);

Note, however, that this makes your DLL non-reusable by another model, unless that model also happens to have the same user command.

You may want to consider implementing the rotate functionality in the DLL instead:

visible double rotate(FLEXSIMINTERFACE) {
  // ...
}

and then linking the user command to the DLL function, as described in the Module SDK documentation:

4509-dllnode.png

Message 3 of 6

mischa_spelt
Advisor
Advisor

Question for @anthony.johnson: does it matter whether you call nodefunction(x, ...) or x->evaluate(...) in this case?

0 Likes
Message 4 of 6

qiu_xiaohong
Not applicable

Thank you for your reply, I can use user command in DLL. But I also want to know if “TASKTYPE_STARTANIMATION” can use in DLL?

0 Likes
Message 5 of 6

SCHamoen
Advisor
Advisor

Why don't you just try it? Basically this is just a macro so just look for it or try typing and intellisense will tell you if it exists or not.

0 Likes
Message 6 of 6

mischa_spelt
Advisor
Advisor

Note that you can actually look inside the FlexSim headers from your Visual Studio project. If you #include "FlexsimDefs.h" it will eventually include allobjects.h which defines the TASK_... constants and more.

0 Likes