I tried closing the 3D model view and open again after writing the codes, but the code still not comes to effect.
Also when I saved and closed the file, I open the file again and the codes I wrote are gone. Why? Thanks
I tried closing the 3D model view and open again after writing the codes, but the code still not comes to effect.
Also when I saved and closed the file, I open the file again and the codes I wrote are gone. Why? Thanks
@Kevin A2 Where did you write the codes? Can you give a screenshot of the tree with the top node? This is very little information to go on but what I guess is that you have written it on the active window? A window that you see is always an instance of the class. So if you open and close the windows or close and open Flexsim, you destroy the instance and your code is gone. I think you should look into creating a module and use that to change the class of the view and write your code there.
For testing it should work if you put it on the instance but have you build the node as Flexscript?
Hi Steven,
I wrote the code on the node "VIEW:/standardviews/documentwindows/Perspective>eventfunctions/XboxInput"
I want to assign an action to the X button of the xbox controller and wrote this:
if (wButtons & XINPUT_GAMEPAD_X) openoutput(theBufferInBewteen);
(where "theBufferInBetween" is a global variable)
Yet when I run the model, I press the X button on the controller and it is not working; while it works when I put the code in a button on dashboard.
Thanks!
Ok this at least answers your question about why your code is missing when you close and open the file. You are putting the code in the right place only thing is that if you save in Flexsim you only save the model. The tree cannot be touched by the user unless you use a module. So once you have your solution working go read up about creating a module to adapt Flexsim. This post tells you where can download the SDK Post with SDK link
For your questions why it is not working you have to simply apply the art of debugging:
1. If you close and reopen the window and you go to: right click->view-> explore structure is your code still there?
2. if your code is still there, is the code called (I'm not sure if you can use the debugger directly but create a message box (msg()) is also a good option
3. if that works you have to check if your conditions are both valid etc.
then you should find out why it not doing what you think it should do..
Hi Steven,
I figured out that I didn't press "Build FlexScript" & "Compile Model" after adding my code; when I press these buttons, and close & re-open 3D view, the code works.
By the way, I found that the Xbox controller is too responsive. When I press (not holding) the X button of the controller just once, FlexSim sees it as I am pressing the button 3 to 4 times. Is there any way to solve this? Thanks.
@Kevin A2 Hi Kevin, compile model should not be necessary if you don't use C++. Build Flexscript should be enough. Considering the too responsiveness, here I have no idea. Maybe @phil.bobo can say something logical about it?
Note that any changes you make to the VIEW tree will be gone when you close and reopen FlexSim. To change the VIEW tree, you should use the Module SDK.
I've tried working on this but I have no idea how to do it
"For example, if you want to execute code just once when it is initially pressed, store a variable on the view to tell when the code has fired but the button hasn't been released yet. Then only execute the code if that variable is false and the button is pressed. In the code, set that variable to true. If the button is not pressed, set that variable back to false."
Could you give an example on it?
Also, it seems that "stick(controller, STICK_XBOX_BUTTONS)" command returns different values when different buttons of controller is pressed (e.g. 4096, 8192, 16384), what does they mean? Thanks.
8 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved