Jump to content
Zum Start hinzufügen

Weitere Informationen

3D-Modellbahn Studio

Eine Vollbild-App auf Ihrem Startbildschirm mit Push-Benachrichtigungen und mehr.

So installieren Sie diese App auf iOS und iPadOS
  1. Tippen Sie auf das Teilen-Symbol in Safari
  2. Scrollen Sie durch das Menü und tippen Sie auf Zum Startbildschirm hinzufügen.
  3. Tippen Sie oben rechts auf Hinzufügen.
So installieren Sie diese App auf Android
  1. Tippen Sie auf das 3-Punkte-Menü (⋮) in der oberen rechten Ecke des Browsers.
  2. Tippen Sie auf Zum Startbildschirm hinzufügen oder App installieren.
  3. Bestätigen Sie durch Tippen auf Installieren.

Empfohlene Beiträge

Geschrieben

Hello @swcurrill , Stephen. You asked me in P.M. for some help to open/close barriers on a crossing. I made this one. ( I cannot attach something in P.M, but who knows some other beginner can also benefit from it here in the forum.) Of course you can always come to the forum directly. Many members are here to help you.

Here we go. For start I used a button, and took the crossing barriers made by @Roter Brummer as an example.

Stephen Barriers.pdfRead this one as explanation.

Stephen Barriers.jpg

Stephen Barriers.mbp

Good luck, and always happy if you can give feedback if it works.

Kind regards, Herman

Geschrieben
  • Autor

Hello @swcurrill , Stephen,

Hello Stephen, only read this if you are ready understanding the previous code above.
This is an answer to your main question : handle 4 barriers together.
---
This solution uses a keyword. A keyword is a special variable on an object. It can be used in a repetition, so that all actions are done on objects with the same keyword. And you have to write those actions only once inside the repetition.

--

Take my demo above, save it under a new name,  and delete the second barrier. Keep the EV.
Change in the properties of the barrier the variation , so that it is an half barrier.

Stephen 2 barriers 00.jpg

---

Click right (mouse button) on the barrier and choose keyword and variables, give it a name.

Stephen 2 barriers 01.jpg

Stephen 2 barriers 03.jpg

---

Done.

Stephen 2 barriers 04.jpg

---

Now use duplicate multiple to create 3 other simular barriers. The keyword is copied automaticly. Now all four have the same keyword.
Change Variations (2x right, 2x left)

---

You need a repetition (iteration).
For objects referencing a keyword. And an iteration name, here Iter.

Stephen 2 barriers 05.jpg

For objects referencing a keyword,  starts a repetition, that handles each object with that keyword one by one, until all are done. The name of the iteration is given. (here Iter, you can take another name, leave it for now).
In each repetition, the iteration Iter is replaced by an object with the specific  keyword. The system does that. A repetition has a start (title)  and end (end line) in brown. The actions between are subject of the repetition.

Change all objects (Level Crossing 01 ) in the actions (for the repetition) by the iteration name Iter.

Stephen 2 barriers 06.jpg

Stephen 2 barriers 07.jpg

Alert !!! Since defer execution is not allowed inside a repetition, we need the "For objects referencing a keyword" more than once in this case.

Result:

Stephen 2 barriers 08.jpg

Just place the four barriers on the road. Have fun testing.

Stephen 02 Barriers.mbp
Greetings, Herman

Bearbeitet von Herman

Geschrieben

Hello Herman,

Unfortunately I have been unable to operate my crossing gates as per you instruction.

One problem is that the properties sub-menues are in German andd I cannot get the logic.

If you have the patience, I will attach a screen grab of the Crossing and ask you /or the community

to show me how to lower the gates triggered by the train entering and close on leaving. The rail contcts are position for testing only

Regards

Stephen

Crossing Gates.jpg

Level Crossing Half-Barrier.jpg

Geschrieben
  • Autor

Hello @swcurrill , Stephen.

2 hours ago, swcurrill said:

Unfortunately I have been unable to operate my crossing gates as per you instruction.

It is difficult to know how far you already are at this moment. Opening closing one barrier with a button, Ok ? Opening closing 4 barriers with a button, Ok ?
If both "Ok", do you only want how you can replace the button with track contacts for an incoming/outgoing train?

3 hours ago, swcurrill said:

The rail contcts are position for testing only

But they are essential to react on an incoming/outgoing train.

3 hours ago, swcurrill said:

screen grab of the Crossing

I think it is better that you export your system or the part with the crossing, and share it on the forum, so we can see what goes wrong.

I see in the picture that you already have two rails on the cross road. Well that is of course beyond the beginners level. I can give you an easy to use solution,
08C870F5-EF37-4E02-A5B6-0454D1E4EBAC but is that what you want ? I thought you are also looking at understanding.

3 hours ago, swcurrill said:

to show me how to lower the gates triggered by the train entering and close on leaving.

However to help, I shall made a little demo that does this for a crossing with one rail. ( but not this evening)

Kind regards, Herman

  • Do not use Animations as in your second picture, use integrated switches.

Bearbeitet von Herman

Geschrieben

Thanks Herman

I think I will step back from this Event programming for a while, I am far out of my Knowledge and capability ( I am 76).

I will try to read as much as is available as regards Control, and then perhaps upload my layout for the Forum.

Thank you for all your help

Regards

Stephen

Geschrieben

Hi @swcurrill

I have recently picked up this thread and whilst Herman is dealing with your problem perfectly I thought you might also benefit from another option. This is one of the great aspects of MBS, there are usually several different ways of solving the same problem. Many members are really great at utilizing elements of Event Management that are quite technical and minimalist in order to get the job done. Then there are the less smart oldies, like me, who try to use some of these more technical bits but who also like to be able to trace their EM work in a more mundane fashion so some of my EM is a bit long winded, but to me more easily followed, especially when trying to correct errors.

So with that in mind I have attached a small demo to show the way that I find best suits me when setting up level crossings.

The track contact are quite simply. The white ones are the counters, this allows for multiple tracks, the black ones on the tracks close the barriers and the yellow ones open them. The black ones on the road act to stop all traffic.

I use only 3 variables. Demo crossing CB1 and trains crossing on CB1, and vehiclesstopCB1democrossing on the road contacts.

So briefly. a train enters a white TC and adds '1' to the variable. It then enters a black TC and the barriers are told to close and all vehicle to stop. Here I close only 2 barriers initially allowing vehicles already on the crossing to clear before the remaining 2 also close. After leaving the crossing and the yellow TC the barriers are told to open and after a brief pause the vehicles begin to move once again.

I hope this explanation is OK for you. Any questions please do not hesitate to ask me.

Kind regards

Pete @220hotwheels

Barrier Crossing demo.mbp

Geschrieben
  • Autor

Hello @220hotwheels Pete, thanks for the support.

Hello @swcurrill , Stephen. It is always ok you come back to the forum with a question. You certainly get help here. I go on with my step by step approach. And will even explain how we can get the job done with two rails later. So I prepared this next, I will come back with more. Here we go.

---

First take my last layout; rename and save.
Place a second rail on the crosspoint and adjust the barriers.
Connect the rails by portals on both sides.

Stephen 3 barriers 00.jpg

----

Place a deceleration contact long before the crossing
( 3D models – Online Catalog – Keywords – Track Contact )
Open the properties of that contact, change to Decelerate to 40 km/h.
We want only one side of the contact to work, so use the correct side.

Stephen 3 barriers 01.jpg

This is only to decelerate the incoming train, so the barriers have all the time to close.
( the further the contact, the less you need this, even a normal TrCt can be used )

Code for the deceleration contact.
Right click on that contact and choose events, new, track contact is triggered.
If the train triggers this contact  when entering the barriers should close.

Go to the code already there for opening/closing the barriers (button).
The closing is the second part of the condition.
Clik left on “For objects referencing a keyword” hold down the left mouse button and drag this to your new event.
Change the name of the event in Close Barriers, and done.

Did you see by moving the title, the inner part of the repetition moves also.

Stephen 3 barriers 02.jpg

----

Place an acceleration contact on the rail just after the crossing.
This is default on Accelerate to 80 km/h, leave it like that for now.
If you did not use the deceleration before,  a normal TrCt could do the job also.

Code for the acceleration contact.
Right click on that contact and choose events, new, track contact is triggered.
If the train triggers this contact  when leaving the barriers should open.

Go to the code for opening/closing the barriers (button).
The opening of the barriers is the first part of the  condition.

This time you have to move the "for" (brown), the time delay (blue) and the second "for" in that order to your new event.

Change the name of the event in Open Barriers, and done.

Stephen 3 barriers 03.jpg

Put a train on the rails and test.
For now only one side is working.

 Kind regards Herman

Stephen 03 Barriers.mbp

59 minutes ago, swcurrill said:

I think I will step back from this Event programming for a while, I am far out of my Knowledge and capability ( I am 76).

That's a pity, said a nearly 75 years old Herman. Posted this and then saw your decision later. I respect your decision.
The 3D studio has so much to learn, and the learning curve is steep and takes a lot of time. But it is worth learning.

Have a nice sunday,

  • Some advice:
    Start with little things on an empty layout and try them out.
    Problems with German, use Google or Deepl translate to look something up.
    Always try out the possibilities of objects manual, before programming in the EV.

Bearbeitet von Herman
typo

Geschrieben

Hi @swcurrill and @Herman

Herman, I concur 100% with your view about EV (EM) and @swcurrill it would therefore be a shame if you, Stephen, took too large a step backwards. Afterall all other members are here to help. No question is too daft and if you need answers in the most basic format then just make that clear. It can be daunting until you really take time to get to grips with the small basics before moving on to more complex matters. I'm also a member of the elderly clan, 79 years young pushing 80. I started with MBS 6 years ago and struggled like crazy in the beginning. Fortunately another member took me under his wing and guided me through the early stages. Since then many other members have helped me to develop my abilities to the point they are now, still got a lot to learn but then that's what makes MBS so magical. There are days when I can spend 8 to 10 hours on a layout. Being honest my real forte lies in creating the layout and scenery, getting everything to work properly is secondary but then just as important.

Clearly it is your decision if you want to take a step back, just remember we are all here to help.

As a small taster of what can be achieved I have attached a few screenshots of my current layout which aims to use the catalogue item SX1 as much as possible, it really is a great catalogue item. Currently I am over 45 separate uses and no where near finished.

Kind regards

Pete @220hotwheels

One of the locks.jpg

SX1 demo layuout 2.jpg

SX1 demo layuout.jpg

The Airport.jpg

The marina.jpg

The station 1.jpg

The station 2.jpg

Geschrieben
  • Autor

Hello members. This was finished this weekend, I hesitated to place it still , so why not? For beginners only.

First take my last layout; rename and save.

Something about keywords. We have seen that a keyword is used in the repetition “for objects referencing a keyword”.
But the power of a keyword goes beyond this.
In stead of let the event management check if something is happening on an object ( example Track Contact is triggered ), it is possible to let it work on all objects with a certain keyword.
The following is an illustration of this principle, we will use in our barriers problem.


Give the deceleration contact a keyword. Name it BeforeCrPt.

Stephen 4 barriers 01.jpgStephen 4 barriers 02.jpg

Give the acceleration contact a keyword. Name it AfterCrPt.


Go to the event in the EM ( EV in German ), Close Barriers. Click on the object (Deceleration contact ) , choose select keyword, then choose the correct keyword name.

Stephen 4 barriers 03.jpgStephen 4 barriers 04.jpg

Do the same for for  Open Barriers, with the correct keyword. ( AfterCrPt )


Copy the deceleration contact and paste it on the other rail far enough from the crossing.
Copy the acceleration contact and paste it on the other rail just after the crossing.

Congratulations, the code that you wrote only once for closing the barriers, works now for each track contact with that keyword. The same for opening the barriers. 


There is only one incoming train at the same time in this layout. So it works.
From the moment that an incoming train is still coming, and an outgoing train opens the barriers, it goes wrong. 
The solution is counting the incoming trains ( +1 to a variable when entering , -1 when leaving ), and only open the barriers if no incoming trains are there. 
But I'm not going to handle that for the moment.


Kind regards, Herman Stephen 04 Barriers.mbp

Bearbeitet von Herman
minor changes

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Push-Benachrichtigungen konfigurieren

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.