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
FAQ Downloads Calendar Search Mark Forums Read

Tips and Tricks Share helpful modeling ideas

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2015
Axel Kohonen
Guest
 
Posts: n/a
Downloads: 22
Uploads: 0
Default Moving folders with user commands when installing from a user library

Hi,

If anyone would want to import the folder structure of their user commands when importing the user commands from a user library then see the answer and the attached .fsl file from Logan at Flexsim support below which explains how to do it.

Axel

Quote:
It is possible to keep the folder structure of the User Commands in the Toolbox, but it's not an automatic process like clicking on the button in the User Commands GUI to add commands to a library for auto install. Instead, it takes some manual coding in the User Library tree to make this happen.

I am attaching a User Library (a .fsl file) to this email as an example of how to do this. To open it, create a new model (so you don't accidentally mess up another model), click on File and then Open User Libraries.

To see the auto installing components of the AutoAddUserCommands library (there are no drag and drop components), click on the arrow next in the AutoAddUserCommands header (or right-click anywhere on the AutoAddUserCommands header) and choose Explore Tree. You should see the newmodelinstall node with 6 subnodes. The first five are the User Commands that are auto installed with each new model and the sixth is the called OrganizeUserCommands.

The OrganizeUserCommands node has an attribute called dropscript that contains the code to auto install the folder structure of the User Commands. If you click on this node, you can see the logic that is used. The first 33 lines are comments on how to use the code and how to use the tree structure of another attribute in the OrganizeUserCommands node called UserCommands. Read over these lines to get a good idea of how to setup something similar with your User Library. I have also included a number of comments with the logic if you want to learn more about the code.

The gist of what is happening is the UserCommands node contains the structure that will be set up in the Toolbox, with nodes like All, A, and B being the folders and the other nodes being which User Commands should be in a particular folder. If you read the comments of the dropscript node you'll get a good idea of how to set up the different folders you want to incorporate into the Toolbox. In the example library, you see a couple of commands in the A folder, a command in the B folder, and both folders contained in the All folder. There is also a fourth command that is part of the All folder. A fifth command is not contained in a folder, so it's not included in the UserCommands structure.

If you wanted to add this functionality to another User Library, you should simply copy over the OrganizeUserCommands node with all its subnodes into the same location of your User Commands in the new User Library. The example has all the User Commands and the OrganizeUserCommands nodes in the newmodelinstall node which means the User Commands and the structure for those commands will be implemented in all new models. If you are using a different way to move your commands to a new model, you may need to do something different with the OrganizeUserCommands library. After copying over this node, you just need to set up the UserCommands tree structure in the way you want the Toolbox to look with your User Commands. Again, reading the dropscript comments should give you a good idea on how to set up the tree structure.
Attached Files
File Type: zip AutoAddUserCommands.zip (2.5 KB, 624 views)
Reply With Quote
The Following 4 Users Say Thank You to Axel Kohonen For This Useful Post:
arunkrmahadeva (09-23-2015), Jing Chen (10-01-2015), Steven Hamoen (09-23-2015), syseo (09-28-2015)
  #2  
Old 10-01-2015
Axel Kohonen
Guest
 
Posts: n/a
Downloads: 22
Uploads: 0
Default

I continued my discussion with support and here is the answer from Logan and the new version of the user library in case someone wants to continue developing the idea.

Axel

Quote:
The code I manually added in the AutoAddUserCommands User Library only changes the User Command structure in the Toolbox and not the logic of the user commands. The commands that are added when a new model is created were initially added to the user library by using the User Commands GUI, specifically with the button near the bottom of the GUI that looks like a circle, triangle, and square next to each other.

So if you have user commands that are automatically installed when a new model is opened and want to change one of those commands after the fact, you can make the necessary changes in the User Commands GUI and add them back into the User Library using the same button I mentioned above - either as an Auto-Install Component or as a Draggable Icon. A note I would like to make with the User Library I sent last time (and the new one I am including with this email) is if you add changed user commands back as Auto-Install components, then you will need to make sure the object called OrganizeUserCommnads (changed to AutoInstallOrganizeUserCommands in this new library) is ranked after all the commands in the newmodelinstall node of the User Library in order for it to work when a new model is opened.

That being said, with this library file I am sending now I have copied over the logic that organizes the user commands in the Toolbox to a draggable icon in the library called DraggableOrganizeUserCommands. The draggable icon works similar to the AutoInstallOrganizeUserCommands logic in that it will only affect how the user commands are organized in the Toolbox and does not affect any of the logic of those commands.

While the two nodes work similarly, I have added more code to the dropscript node of DraggableOrganizeUserCommands that is not in the other node. This new code checks to see if there is already a top level folder in the Toolbox with a given name. If there isn't already a folder with the same name, then it creates a new folder in the toolbox and places any subfolders and/or user commands into that top level folder. If there already is a top level folder with the same name, then it replaces that folder with whatever structure is defined in the UserCommands node (subnode of the DraggableOrganizeUserCommands node). That means every time the DraggableOrganizeUserCommands object is dragged out of the user library and into the model, the structure of the user commands in the Toolbox will be overwritten with the structure defined in DraggableOrganizeUserCommands.

So to answer your questions, the AutoAddUserCommands library does not overwrite any user commands, because the AutoInstallOrganizeUserLibrary functionality is only executed when a new model is created - so there can't yet be any user commands in the model. However, the user commands are added to the model as part of the autoinstall functionality of the library and then the code in the dropscript organizes those commands in the Toolbox (after they are installed).

To do what you want to do - overwrite a user command in a model that already has that command - you need to add that user command to a user library as a draggable component. However, if you need to reorganize the structure of the commands in the Toolbox without wanting to move them around manually in the Toolbox, you can use something like the DraggableOrganizeUserCommands object to do just that (after setting up the UserCommands node in the user library's tree).
Attached Files
File Type: zip AutoAddUserCommands-v2.zip (2.7 KB, 539 views)
Reply With Quote
The Following User Says Thank You to Axel Kohonen For This Useful Post:
Jing Chen (10-01-2015)
Reply

Tags
folder, user commands, user library

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning multiple num's from a user commands Benjamin Cohen Q&A 1 05-27-2015 07:25 AM
Problems with user commands ..!! mearjun Q&A 5 08-22-2013 01:20 AM
User Commands mearjun Flexsim Student Forum 4 05-01-2013 06:01 PM
Transfer User Commands to a DLL Stephan Seidel Q&A 4 02-03-2012 03:18 AM
groups in user commands Carsten Seehafer Q&A 2 07-08-2011 01:34 AM


All times are GMT -6. The time now is 11:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.