ATTENTIONThis 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 |
#1
|
||||
|
||||
train carriages
Hello
Is it possible to connect an engine with a few carriages, so that i get the required length of the train. I tried making one engine a bit long, but that doesnt look good, just seeing a rectangular block moving. I would like to get the snake flow, across bends, so that the engine, followed by a few carriages meets the required length and also moves like how a train is supposed to move....... Thanks...... |
#2
|
|||
|
|||
Rail API
Hi,
Have you looked at the Rail API? It may help you out: http://www.flexsim.com/community/for...do=file&id=127 |
#3
|
||||
|
||||
Hi
Hi
I haven't dealt with Libraries before, so could you advise me what i have to do in regards to this. I did download the file, i copied all the 4 files into my Flexsim Library folder and i tried opening the sample model, but i dont have anything working. Please help !! |
#4
|
|||
|
|||
Hi,
Make sure you have the files in the right place from the unzip. RailAPISample should be at: \Flexsim5\libraries\ RailAPISample.fsm And the rest of the files at: \Flexsim5\libraries\RailAPI If you then open a blank Flexsim model and open the library by going to the library icon grid (if this is not open you can open it from View > Modelling Utilities >Library Icon Grid) and pressing the open libraries button (second from the left at the top). Browse to the RailAPI.fsl and press open. Then open the Flexsim model using File > Open Model. You should see a 3D window and a script file. If you execute the script file the trains should move. |
The Following 2 Users Say Thank You to mark.gormley For This Useful Post: | ||
Nischith Kashyap (04-11-2011) |
#5
|
||||
|
||||
Hello
We are working on a model, which has trains of different lengths, moving to different stations ( using a task sequence to mention the different x,y values of each station. We got the Rail API working, and the sample model works too, but what we need is just a train ( Transporter or a basic TE ), with a few carriages behind it ( Again maybe Transporters or Basic TE) representing the train length, move from one station (x1,y1) to another station (x2,y2). I did have a look at the script in the sample file, and that was good work, but we actually dont need our trains to couple up, and decouple carriages. We did try editing the script, but we were not able to get the trains move like how we wanted them. Could some one please help. Thanks.... |
#6
|
||||
|
||||
If you don't tell us what you did, we can't tell you what you did wrong!.
So please post your model (or in this case maybe just the script) and tell what you want it to do. Then somebody might be able to tell you what you have done wrong. Now it stays a guessing game |
#7
|
||||
|
||||
We have attached the code below. what we have done is just changed the code which was in the script file in the Rail API Example. What we need is the dispatcher (Train ) to move all its carriages from a station1 ( X1, Y1 ) to another station2 ( X2, Y2 ) and so on, like a task sequence....
The code we have written for the train is ... resetmodel(1); maintenance(10, 0); double edge1dist = getrailedgedist(1); double carlength = 1.1;// Is this the value for the total train length (1.1mts)?? treenode carsdisp = node("/Cars", model()); int nrcars = nrop(carsdisp); treenodearray cars = makearray(nrcars); double trainlength = nrcars*carlength; int i; treenode sequence = createrailsequence(); for(i = 1; i <= nrcars; i++) { cars[i] = outobject(carsdisp, i); addrailtraveler(sequence, cars[i], (nrcars-i)*carlength); } // We want to move the train from station 1 ( X1, Y1) to station 2 (X2, Y2) //and a few more stations after //that in a task sequence treenode path = createrailpath(1, 0, 4, trainlength + 2); treenode move = addrailmove(sequence, path, 1,1,1, trainlength, 0, 0); startrailsequence(sequence); go(); this is the code we have written for the train to move in a task sequence. treenode newtasksequence = createemptytasksequence(node("/Transporter13",model()),0,0); for(int i=1; i<= gettablerows("TimeTable1"); i++) { inserttask(newtasksequence,TASKTYPE_TRAVELTOLOC,NU LL, NULL, gettablenum("TimeTable1",i,1),gettablenum("TimeTab le1",i,2),0,gettablenum("TimeTale1",i,3)); inserttask(newtasksequence,TASKTYPE_DELAY,NULL,NUL L,30,STATE_BUSY); } dispatchtasksequence(newtasksequence); Please if some one could help us out with this ... thanks... |
#8
|
||||
|
||||
If you don't need to decouple/recouple, then you can just chop off most of the code at the end, as follows:
Code:
resetmodel(1); maintenance(10, 0);// set spline tension to 0 double edge1dist = getrailedgedist(1); double carlength = 1.1; treenode carsdisp = node("/Cars", model()); int nrcars = nrop(carsdisp); treenodearray cars = makearray(nrcars); double trainlength = nrcars*carlength; int i; treenode sequence = createrailsequence(); for(i = 1; i <= nrcars; i++) { cars[i] = outobject(carsdisp, i); addrailtraveler(sequence, cars[i], (nrcars-i)*carlength); } // move the train from edge 1 to edge 4 treenode path = createrailpath(1, 0, 4, trainlength + 15); treenode move = addrailmove(sequence, path, 1,1,1, trainlength, 0, 0); startrailsequence(sequence); go(); |
The Following 4 Users Say Thank You to Anthony Johnson For This Useful Post: | ||
Steven Hamoen (04-23-2011) |