Cylinder animation

Cylinder animation

Christian_Garimberti
Advisor Advisor
1,396 Views
15 Replies
Message 1 of 16

Cylinder animation

Christian_Garimberti
Advisor
Advisor

Hi everyone,

is there a way or workaround to animate an hydraulic cylinder?

i cannot prepare the animation in 3dsMax and import it, i have to move my model interactively in VR with the Vive.

1.png

Thank You

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Accepted solutions (1)
1,397 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable

Hi,

 

You can use the aimConstraint function to achieve this kind of effect.

Basically if you have a piston like yours, you're supposed to have two parts.

Part one is fixed to the frame (let's call it fixPiston)

Part two to the hinge (let's call it mobilPiston)

and Sphere to orient the piston (let' call it Sphere)

 

The script will be like this:

 

 

createAimConstraint(["fixPiston"], ["Sphere"], "mobilPiston")

createAimConstraint(["mobilPiston"], ["Sphere"], "fixPiston")

 

 

Then you just have to put your mobil part in the Hinge in your scenegraph and piston parts will face each other everytime.

The biggest contraint is you 're supposed to have both element of your piston at the 0 of the scene and facing down.

 

hope it will be helpfull.

0 Likes
Message 3 of 16

Christian_Garimberti
Advisor
Advisor

Thank you for the reply!

Unfortunately i have to put 3 cylinder i my model and 2 of these must rotate with half of the structure...

This is a simplified view of the first cylinder

2.png

and this is what i need to do...

3.png

... to much work only to see something "beautifull" ...

thank you

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 4 of 16

Anonymous
Not applicable

You just have to duplicate the script as many time as you have pistons with new names.

 

createAimConstraint(["fixPiston"], ["Sphere"], "mobilPiston")
createAimConstraint(["mobilPiston"], ["Sphere"], "fixPiston")
createAimConstraint(["fixPiston1"], ["Sphere1"], "mobilPiston1")
createAimConstraint(["mobilPiston1"], ["Sphere1"], "fixPiston1")
createAimConstraint(["fixPiston2"], ["Sphere2"], "mobilPiston2") createAimConstraint(["mobilPiston2"], ["Sphere2"], "fixPiston2")

//and so piston.gifon


 

0 Likes
Message 5 of 16

Christian_Garimberti
Advisor
Advisor

ops...

maybe i loose something...

i have the piston, made of two parts...

i have to set the pivot of the twoo pars tin the joint, correct?

i have to put each part inside the mobile object?

the sphere, mast be in the origin of the scene?

 

thank you

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 6 of 16

Anonymous
Not applicable
Accepted solution

Unfortunately I'm not able to upload my file on the forum ! Don't know why !

But basically the steps are :

- Place both part of your piston at the zero of the scene and facing down. It can be two groups with all parts in each other.

-freeze all the transform on it.

-If it's the same piston each time, duplicate it as many time as needed.

-Then create the script depending on the names of your parts.

-Apply the script.

-Move the pistons parts in position and in the scene graph to parents them with the object they will move with.

-Now you just need to animate your objects and pistons will follow the movement.

 

Well it's not that easy to explain it by text, Sorry.

Message 7 of 16

Christian_Garimberti
Advisor
Advisor
Everything ok!!
Only 1 thing...
after moved the cylinder pieces under the correct parent i had to re run the script.
but then everything works as expected!

Thank you very much!

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 8 of 16

Anonymous
Not applicable

You're welcome !

 

To be more clean and if in the future you want to use your file in VR, you can move your script in a Variant Sets, then you will be able to relaunch it with a hotkey.

0 Likes
Message 9 of 16

Christian_Garimberti
Advisor
Advisor
thank you another time!
Constraints in VRED allow me new possibilities for animation!
if i can i will post the results of my work.

bye
Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 10 of 16

Anonymous
Not applicable

 

pistonscreengrab.PNGHi, I am attempting to recreate the same setup, as it would greatly reduce the effort with animating this kind of thing. However my scripting skills or lacking, and as you can guess, it is not going well. I was wondering if you could explain in a little more detail how to create the setup, especially in regards to the position of pivot points, what to use for the upSource. Here is a screengrab of my example part I am  working with if that helps.

 

Many thanks!

0 Likes
Message 11 of 16

Anonymous
Not applicable

Hi,

About the pivot point, as it's greatly recommand to link new groups for this effect, you don't really care. But to get something really realistic with weird rotations, it's better to put both part of your piston at zero and facing -Z.

The Up Source is the second object of the code:

createAimConstraint(["fixPiston"], ["UpSource"], "mobilPiston")

createAimConstraint(["mobilPiston"], ["UpSource"], "fixPiston")

 If you want to test is on a basic case study, create two cones (name them Cone1 and Cone2) and a sphere, both cones have to face -Z, then freeze the transform and apply and run this code in the script editor.

createAimConstraint(["Cone1"], ["Sphere"], "Cone2")

createAimConstraint(["Cone2"], ["Sphere"], "Cone1")

 Then move the cone and the sphere to see the effect.

0 Likes
Message 12 of 16

Anonymous
Not applicable

Many thanks for the reply!

 

I have got the cylinders working now, and managed to do so without including an upsource.

 

 

createAimConstraint(["tpin1"],[],"bshaft1")

createAimConstraint(["bpin1"],[],"tshaft1")

 

 

I have no idea if this will cause unintended problems further down the road, but it seems to do the trick 🙂

 

Thanks again.

0 Likes
Message 13 of 16

Anonymous
Not applicable

You're welcome !

 

The Up Source is useful if you don't want your piston to turn on Up axis when the base points are crossing themself on X or Y axis.

The best way is to create a small sphere as Up source and group it with one of your part, then it will move as the linked part and constraint both parts to prevent any wrong rotation. You just have to make the sphere invisible to keep something visually good.

0 Likes
Message 14 of 16

Christian_Garimberti
Advisor
Advisor

Hi,

do you think i can manage also this situation? not cylinder but an elevator that lift an arm.

Annotazione 2019-02-02 183253.jpg 

The yellow part runs on the red guide, up and down. to lift the violet arm.

I have to animate this mechanism.

ideas?

 

Thank you

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 15 of 16

Anonymous
Not applicable

Well with this constraint I don't think it's possible, but if you create a rotation to rotation constraint, it can probably works great.

For example, the rotation of the red part is equal to the invert of the rotation of the purple one, and then you can like the translation of the yellow to the blue one mathematically ... or something like that.

Honestly my Python skills are not good enough for that.

 

Hope it can help

Message 16 of 16

Christian_Garimberti
Advisor
Advisor
Me too i think is not possible...
I'll try to simulate the movement synchronizing the parts with the curves.
The only thing i have done is to keep the blue part facing the pin on the red arm, using CreateAimConstraint.
Then i move the lifter up and down and rotate the red arm to visually maintain the joint.
It is enough. it is a mechanism prototype. i only need to explain it.
Thank you
Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes