question

qiu xiaohong avatar image
1 Like"
qiu xiaohong asked Mischa Spelt edited

how to use user command in DLL

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

user command
无标题.png (13.3 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Mischa Spelt avatar image
3 Likes"
Mischa Spelt answered Mischa Spelt edited

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".

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:


usercommandintree.png (471.9 KiB)
dllnode.png (230.6 KiB)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image Mischa Spelt commented ·

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

0 Likes 0 ·
qiu xiaohong avatar image qiu xiaohong commented ·

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 0 ·
Steven Hamoen avatar image Steven Hamoen qiu xiaohong commented ·

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 0 ·
Mischa Spelt avatar image Mischa Spelt qiu xiaohong commented ·

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 0 ·