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-28-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default Button in model view

Hi,
i want to have some buttons on my objects. If they are pressed (double LM would be ok) then some functionality gets executed.... simple so far..
My plan was replacing the gui for those button objects with an empty gui which is executing something or at least can send a message to the objectfocus object and then closes it self....
I am experiencing two problems:
1. I can´t get the reference to the objectfocus object. I tried this on the onOpen of the GUI :

treenode focus = node("@>objectfocus+",c);
pt getname(focus); pr();

This does not work here, but it is working if I put a button to the gui and enter the code to the onPress attribute.

2. I get a lot of open guis in the active view treenode, which I can´t see.
I tried to close the gui on the onOpen attribute with

closeview(c);
destroyobject(c);

So the gui disapears, but the node is still there, and there are many more nodes than there should be...

Well, all I need is a button in the modell view or in a visual tool....
__________________
kind regards Nico.
  #2  
Old 11-29-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

Nico,
1. If the code is entered in the OnOpen, then the reference c points to the main gui. Therefore, the path should be node(">objectfocus+",c). Remove the @.

2. You might try using the OnPreOpen to destroy the gui, instead of the OnOpen. There might be some weird implications of trying to destroy the gui from within its own code, but the OnPreOpen kind of has some custom logic in the engine that takes that into account and lets the user do that if needed.

If you just want to execute some logic when the object is double-clicked, you might just try adding an OnClick event to the object. Go into its object tree. I usually put the node in >behaviour/eventfunctions. Add a node and give it the name OnClick, then right click on the main object in the tree and choose Edit|Rebind Object Attributes. Then add flexscript code, toggle the node flexscript, etc. Here's some sample code:

Code:

int code = clickcode();
switch(code)
{
 case LEFT_PRESS: 
   pt("left press");pr();
   break;
 case LEFT_RELEASE: 
   pt("left release");pr();
   break;
 case RIGHT_PRESS: 
   pt("right press");pr();
   break;
 case RIGHT_RELEASE: 
   pt("right release");pr();
   break;
 case DOUBLE_CLICK: 
   pt("double click");pr();
   break;
}
The Following 9 Users Say Thank You to Anthony Johnson For This Useful Post:
Tom David (11-30-2008)
  #3  
Old 12-01-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Smile

Hi Anthony,
I used the onClick code.. So I can have a trigger for every event in the attribute list.. but if you change this trigger, you have to compile...
This works great .. thank you..
__________________
kind regards Nico.
  #4  
Old 12-01-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

Nico,
If the trigger is flexscript, you shouldn't have to compile. You can either build flexscript from the main menu, or right-click on the OnClick attribute and select Build|Build Node Flexscript.

Yes, you can have an event associated with every On... attribute in the attribute list. However, by adding that event to the object, you override any functionality that is done by the object in the library, so you may not want to do that for all attributes. We still need to add a command like executeinheritedcode() that lets you call the standard functionality from within your own attribute's code.
The Following 4 Users Say Thank You to Anthony Johnson For This Useful Post:
RalfGruber (12-03-2008)
  #5  
Old 03-31-2009
Kurt De Cock Kurt De Cock is offline
Flexsim User
 
Join Date: Mar 2009
Location: Gent, BE
Posts: 4
Downloads: 5
Uploads: 0
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0
Kurt De Cock is on a distinguished road
Default

Quote:
Originally Posted by Anthony Johnson View Post
..We still need to add a command like executeinheritedcode() that lets you call the standard functionality from within your own attribute's code..
Hi Anthony

Is there any way to keep the standard functionality in case I am overriding an existing eventfunction or do we have to wait for the executeinheritedcode() function ?

For example, I want to use a flexscript 'OnSend' eventfunction in a 'Source' object. This overrides the 'OnSend' eventfunction of the 'FixedResource' object. If I do this, the 'Source' sends one item and it stops. Can I use flexscript to keep or implement the original 'OnSend' functionality of the 'FixedResource' object ?

Kurt
  #6  
Old 03-31-2009
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

If you don't want to overwrite the existing functionality, why don't you just put your code in the OnExit trigger?
  #7  
Old 04-02-2009
Kurt De Cock Kurt De Cock is offline
Flexsim User
 
Join Date: Mar 2009
Location: Gent, BE
Posts: 4
Downloads: 5
Uploads: 0
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0
Kurt De Cock is on a distinguished road
Default

Because I want to create a custom object, i.e. a batching/combiner machine. I already created this machine and also the functionality I need using the 'entrytrigger' and the 'exittrigger'. But now I want to place the flexscript of those triggers in the 'OnReceive' and 'OnSend' eventfunctions. I managed to override these eventfunctions in c++ but I'm not really a c++ coder and compiling every time you reopen the model is not an option.
  #8  
Old 04-02-2009
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

Kurt,
Unfortunately there's not a way right now to do this in flexscript. We've worked on extending this type of functionality for C++/DLLs, but that hasn't been extended yet to flexscript.
The Following User Says Thank You to Anthony Johnson For This Useful Post:
Kurt De Cock (04-02-2009)
  #9  
Old 04-02-2009
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

Kurt,

You could also copy all of the code of the OnReceive and OnSend functions of the mother on eventtrigger and then add your own code there as well.

Other point, have you thought about writing your code in the triggers like you have and then call as last function in that trigger a different node that acts as user trigger? Then in the GUI you can point to that new trigger (usually a node under labels) So that way you have your code nicely tucked away and still give somebody the possibility to add it's own exit and entry triggers.

Steven
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Phil BoBo (04-02-2009)


Thread Thread Starter Forum Replies Last Post
Make sure you stop model with the stop button before collecting state based statistics Paul Dowling Tips and Tricks 2 06-10-2008 08:10 AM
New view setting KelvinHo Q&A 2 05-29-2008 01:44 AM
Get view reference AlanZhang Q&A 3 03-13-2008 08:51 AM
adding a button on the tool bar Pablo Concha Q&A 4 09-13-2007 10:46 AM
Controlling the camera view to be focused on a moving object in your model. Regan Blackett Tips and Tricks 0 08-03-2007 10:12 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.