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 > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 11-21-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default how to open another GUI

when I click a button in GUI1, I want to open GUI2.

How to program in the onpress trigger of the button?
thanks.
  #2  
Old 11-22-2008
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default Createview command

Syntax: createview(str viewpath, str objectfocus, str viewfocus)

..so viewpath could be "MAIN:/project/model/Tools/GUIs/MyGUI".

To use the objectfocus or viewfocus attributes of your GUI to reference an object it represents, then the paths as strings should be passed in as the 2nd and 3rd paramters.

Jason
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post:
qin tian (11-22-2008)
  #3  
Old 11-24-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Qin,

The easiest and fastest way to learn how to program GUIs is to go and pirate what you want to do from another GUI. The easiest way to do that is to open the GUI you want to pirate from and then right click on it and click on View > Explore Structure. This will open the tree view of the GUI you clicked on. Depending on where you right clicked on the GUI it may not open the tree view up to the base portion of the GUI but you can right click in the tree view and select View > Up to move up until you get to the base if you need to.

Yes, this is how we all do it even the developers who made the GUIs. Why? Because nobody makes GUIs enough to remeber exactly how they coded something and because it's easier and faster than actually doing it over from scratch.

Good Luck,
Brandon
__________________
thats not normal.
The Following 3 Users Say Thank You to Brandon Peterson For This Useful Post:
qin tian (11-24-2008)
  #4  
Old 11-24-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default

By the way, there is command, such as:

mainmenucommand("File|Open...")

If I want to execute other menu item, such as "File|Save Model As...", what is the exact parameter. It seems that the parameter is not the same as the menu item.
  #5  
Old 11-25-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Qin,

Look in the view tree and go to rootmenu/replace and simply look how it is currently done and then copy and adapt it to your own needs.

Steven
The Following User Says Thank You to Steven Hamoen For This Useful Post:
qin tian (11-25-2008)
  #6  
Old 11-25-2008
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

mainmenucommand() calls functions that were on Flexsim1's original menu. The menu has changed significantly since then, and the command hasn't been updated accordingly. Only certain things work for that command, and you can usually only find what those are by looking at what the code behind what various Flexsim buttons and menus are doing. Some of them use it; others do not.
The Following 5 Users Say Thank You to Phil BoBo For This Useful Post:
RalfGruber (11-28-2008)
  #7  
Old 01-01-2010
zhang xin zhang xin is offline
Flexsim User
 
Join Date: Dec 2008
Location: China
Posts: 136
Downloads: 147
Uploads: 0
Thanks: 81
Thanked 6 Times in 6 Posts
Rep Power: 150
zhang xin is on a distinguished road
Default

Quote:
Originally Posted by Jason Lightfoot View Post
Syntax: createview(str viewpath, str objectfocus, str viewfocus)

..so viewpath could be "MAIN:/project/model/Tools/GUIs/MyGUI".

To use the objectfocus or viewfocus attributes of your GUI to reference an object it represents, then the paths as strings should be passed in as the 2nd and 3rd paramters.

Jason
Hi, jason, your solution works. But I have another question, how to determine if the MyGUI is already opened?
  #8  
Old 01-01-2010
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

The solution I normally use is to search through the acitve views and check if the node exists. I compare the names, but because the node name is the name plus a number I just compare the beginning of the name.
Maybe there is a better solution, which I do not know.

I use the following code:

Code:
 
//SEARCH THROUGH ALL ACTIVE VIEWS
for(int iContentCounter = 1; iContentCounter <= content(node("/active",views())); iContentCounter++ )
{
//IF NAME EQUALS SPECIFIC NAME
if(comparetext("MyGUI",stringcopy(getname(rank(node("/active",views()),iContentCounter)),1,5) ))
{
msg("MyGUI","MyGUI already open!");
break;
}
}
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following 2 Users Say Thank You to Tom David For This Useful Post:
zhang xin (01-02-2010)
  #9  
Old 01-02-2010
zhang xin zhang xin is offline
Flexsim User
 
Join Date: Dec 2008
Location: China
Posts: 136
Downloads: 147
Uploads: 0
Thanks: 81
Thanked 6 Times in 6 Posts
Rep Power: 150
zhang xin is on a distinguished road
Default

If I have two guis, MyGUI and MyGUI1, and MyGUI1 is opened and MyGUI is closed, then, the solution will have problem. How to resolve it?
  #10  
Old 01-03-2010
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

I woud just name one GUI MyGUI1 and the other MyGUI2 and change the stringcopy to 1,6 and make two if-statements.
Or name the GUI depending on the object like MyGUI_ObjectName. And change the stringcopy and compare the object name with the GUI name cut with stringcopy. This would be a more general solution.

I am sure there are situations where some solutions might not working, but normally there is an "easy" solution.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
  #11  
Old 01-03-2010
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

If you only want to have one instance of a GUI and activate it when you call the GUI for the second time, I am using this code:

Code:
//if window is already opened, just activate instead of making another one.
setcurrent(checkforexistingview(c));
if(objectexists(current))
{
  makeactive(current);
  destroyobject(c);
  return(0);
}
This code I have borrowed from the X_ models Flexsim have posted on this Forum.

Create a node in the GUI called OnPreOpen and add the code first.

Lars-Olof
The Following User Says Thank You to Lars-Olof Leven For This Useful Post:
Tom David (01-03-2010)
  #12  
Old 01-03-2010
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Lars-Olof,

Thanks for your hint and I checked in my model template the PreOpen node and found that I am using a command to do the job.

In other words is there a command to do the job:
standardpreopen(obj object)
Description: For developer use. Queries if there are any open windows that are the same as the current window being opened. If so, then the current window is closed.
Example:standardpreopen(c)

So the easiest way is to use standardpreopen(c); in the PreOpen node.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following User Says Thank You to Tom David For This Useful Post:
Lars-Olof Leven (01-04-2010)
  #13  
Old 01-04-2010
zhang xin zhang xin is offline
Flexsim User
 
Join Date: Dec 2008
Location: China
Posts: 136
Downloads: 147
Uploads: 0
Thanks: 81
Thanked 6 Times in 6 Posts
Rep Power: 150
zhang xin is on a distinguished road
Default

Hi, I upload a model, it seems that neither solution works, why?
Attached Files
File Type: zip 1.zip (30.5 KB, 199 views)
  #14  
Old 01-04-2010
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

Change the code for your button openGUI 2:
Code:
From:
createview("MAIN:/project/model/Tools/GUIs/GUI 2");
To:
createview("MAIN:/project/model/Tools/GUIs/GUI 2","MAIN:/project/model/Tools/GUIs/GUI 2");
Now it should work.

Lars-Olof
The Following 3 Users Say Thank You to Lars-Olof Leven For This Useful Post:
zhang xin (01-04-2010)


Thread Thread Starter Forum Replies Last Post
error:Unable to open storage set. make sure the file exists. qin tian Q&A 3 11-17-2008 01:05 PM
How to get a full path of the current open Flexsim model file. Regan Blackett Tips and Tricks 7 04-17-2008 10:39 AM


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.