ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Tips and Tricks
Downloads

Tips and Tricks Share helpful modeling ideas

  #1  
Old 08-03-2007
Regan Blackett Regan Blackett is offline
Flexsim Consultant, Forum Moderator
 
Join Date: Jul 2007
Posts: 14
Downloads: 19
Uploads: 16
Thanks: 0
Thanked 14 Times in 6 Posts
Rep Power: 183
Regan Blackett will become famous soon enoughRegan Blackett will become famous soon enough
Default 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"
Using this method, we can use another code editor, such as Microsoft Visual Studio to edit your C++ code. You also will not need to worry about whether or not the code is correctly imported into Flexsim after you make any changes in that C++ file.
  #2  
Old 09-03-2007
tsconcept's Avatar
tsconcept tsconcept is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 8
Downloads: 4
Uploads: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
tsconcept is on a distinguished road
Default 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.



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.