Jump to content

Transformation demo V7


Recommended Posts

Hello @simonjackson1964 , because not so related to Jef Goris's topic, I come back here.
Users that want it can still find that layout here. I made it in V7. 

Kind regards, Herman

Remark The mbp "put object on top of another object" is the full demo for transformations and rotation.  V7

Edited by Herman
Link to comment
Share on other sites

I went back and found it, because unloading a train full of pallets and moving them all back to their start points by any means other than magic seems like a nightmare scenario.

It's odd, suddenly finding things that you assume other people already know, only to discover that they don't...

This is the script I use to put all the pallets back in their assigned start locations so that they can be re-loaded on the next train:


"pallets" is a list parameter passed to the user-defined event. Each pallet has an X, Y and Z in a table called "Start Position".

For anyone new to MBS reading this:

The angles in Lua are in radians, and there are 6.28318 radians in 360° (or 2 x π). π is therefore 180° so ½ x π is 90°. (Based on the mathematical truth that the circumference of a circle = 2 x π x the radius).

The link function removes the link established between the pallet floor and the pallet by the crane, when it placed the pallet there. Transformation.position puts the pallet back at its start location. (Although I'm wondering if "resetPosition" might do that? I've got something that works, and "if it works, don't fix it".) Because the pallet has been moved and rotated and moved and rotated, by the fork lift, by the crane and by the train itself, I need to ensure that the pallet is facing the right way for the forklift to pick up again.

As I hinted previously in a different thread, without reading the dire warning Herman gave, I tried using the "rotate(x,y,z,w)" function and this basically removes your ability to move the object at all. The only solution is to delete it and make a new one!

But resetRotation() puts the object to (x=0, y=0, z=0). And then rotateZ(θ) where θ is the angle you want the object at in radians puts it exactly there. This saves trying to find the current angle of the object, subtracting that from the angle you want it at, to work out the angle to rotate it by.

Incidentally the easiest way to get the For...End loop in Lua, is to define an empty iteration in the EV and then convert to script...Screenshot2023-08-05143443.thumb.jpg.e72350c00d8badf6585b69c18aa9bcfb.jpgScreenshot2023-08-05143546.thumb.jpg.95ddc963c6f9d540bf15f10a2bf02b77.jpg

Link to comment
Share on other sites

Hello members, thanks to some idea's from @simonjackson1964  I gave the V7 demo an upgrade, and did put some new things in it. 

Let us say you have a freight train loaded by a crane with cargo. Then the train departs and took the cargo to another place. After a while you want all the cargo back on the start place, so the train can come and the crane can reload the cargo that is now exact on the same place as before. 
Then you need transformations. And that goes beyond the graphical EV. You need Lua script.

This demo just give an introduction of transformations with easy to comprehend transformation instructions in the different samples.
However this demo is not for starters / beginners of the MBS. You need a certain practice and knowledge of the graphical EV before, and even some starting notes of programming.

On the other side, there is for experienced script users no news under the sun with this demo.

I made it in the beginning of 2022, in V7, so I reworked it in V7. 
Download only if interested in starting with transformations, and willing to do some Lua script. 
You find a lot of comments in the script.

You find it in the catalog under Finished Layouts. CDD311DD-1283-426C-B6A2-F0D21AC14C1A ( from V7 on )


Kind regards, Herman

Edited by Herman
Link to comment
Share on other sites

Hallo @Herman

it was a great idea of yours to comment in detail the event management in Lua. This makes the examples much easier to understand because the flow is explained. Thanks ! But because the comments are written in English, I translated them into German for me and make them available as a PDF file for all interested readers. I have followed your EV.


es war eine großartige Idee von dir, die Ereignisverwaltung in Lua ausführlich zu kommentieren. Dadurch sind die Beispiele sehr viel besser zu verstehen, weil der Ablauf erklärt wird. Danke !

Weil die Kommentare aber auf englisch geschrieben sind, habe ich sie für mich deutsch übersetzt und stelle sie allen interessierten Lesern als PDF-datei zur Verfügung. Ich habe mich an deine EV gehalten.

Viele Grüße, Henry


Link to comment
Share on other sites

10 hours ago, Henry said:

es war eine großartige Idee von dir, die Ereignisverwaltung in Lua ausführlich zu kommentieren

Hello @Henry.  Thank you for that remark. :)

10 hours ago, Henry said:

habe ich sie für mich deutsch übersetzt und stelle sie allen interessierten Lesern als PDF-datei zur Verfügung

Waw Henry, great job, very nice, I just looked at it. (y) As a Belgian ( Flemish side ) my language is Dutch and I can read a bit of German as a related language. But not to speak or write German. I had not the courage of a translate with an internet translator. So thanks again.  

Kind regards, Herman

@Henry , am I allowed to take your German text and put it in my layout and republish it ? I will mention of course it's your translation. 

Edited by Herman
Link to comment
Share on other sites

vor 5 Stunden schrieb Herman:

am I allowed to take your German text and put it in my layout and republish it ?


 with pleasure, of course you may do that. I would be happy about it.

gerne, natürlich darfst Du das machen. Ich würde mich darüber freuen. 



P.S. I can also send you a Word file to copy and paste.
Ich kann dir auch eine Word-Datei zum Kopieren und Einfügen schicken.

Edited by Henry
Link to comment
Share on other sites

Hallo Mitglieder, in diesem Layout findet ihr jetzt auch Kommentare auf Deutsch, dank Henry. 
Veröffentlicht mit der gleichen ID.
Mit freundlichen Grüßen, Herman 

CDD311DD-1283-426C-B6A2-F0D21AC14C1A ( from V7 on )

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...