ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
|
Downloads |
Tips and Tricks Share helpful modeling ideas |
#1
|
|||
|
|||
How to get the Global Code Functionality from Version 3 into version 4.
Flexsim v4 uses Global C++ to replace Global Code in Flexsim v3. However, you can still get the Global Code menu item by manually adding your code in the following node in Flexsim tree:
model/Tools/GlobalVarGen>variables/usercode You need to toggle the node as Global C++ by right clicking on the node then choosing Build. Then you need to execute the command updatetoolsmenu() in a Script window. After finishing all the above, the Global Code can be found under Tools menu. Flexsim v4's new Global C++ feature is actually more flexible than Flexsim v3's Global Code feature. In v4 you can toggle any blank text node in the model tree as Global C++, and the text of that node will be compiled as C++ code at the global scope. This allows you to distribute your code across multiple, logically separated nodes, instead of having to put a huge mess of code in one spot. Standard practice is to add these nodes in the model tools folder, and organize them as you like. Just add a node (right click on the Tools folder and choose Edit>Insert Into), give it text data (right click on the new node and choose Insert>Add String Data), and toggle it as Global C++ (right click and choose Build|Toggle as Global C++). Then write the global c++ code in the node's text data. Before you jump into writing global code to just do things like create global variables (int, double, treenode, etc.), be sure and check out v4's new Global Variables gui in the Tools menu! Another way to include Global C++ code in a model is to put it in a CPP file. Then create a Global C++ code under Tools menu. And in that Global C++ code, write something like: Code:
#include "PathToCppfile\\CppFileName.cpp" |
#2
|
||||
|
||||
Ranking of Treenodes
Converting Global C-Code with the above method works.
Just two small additions: Convert all the fsnode* pointers (maybe by copying the code to MS Word to replace) to treenodes. If you are using Global Variables in your Code be shure the node with the initilization of the variables is in the ranking above the node of the object which is using it. |