Notifications
Clear all

[Closed] Help needed for gear script or expression

Hello guys,

I need your help for “scripting”.

Gear1 is rotating on z axis (both sides), Gear2 is linked to G1, but only in positive (or negative, I don’t remember).

I want to assign a controller on gear2.Z Rotation (cript or expression), something like that :

if G1.Z Rotation=positive then G2.Z Rotation=G1.Z Rotation else 0

or

if G1.Z Rotation=negative then G2.Z Rotation=G1.Z Rotation else 0

I need to setup a 80 moving parts watch, so I need to use “Assign Controller” function.

hope you can help, and hope to be clear…

Best regards.

8 Replies

If you do end up using script controllers for this, if your timeline is very long, you may experience much slowdown. This is cause your rotation of cog 2 is relative and dependent. Relative to it’s starting point, and dependent on whether cog 1 has rotated it in the previous frames or not. So for every object that you want to do this kind of calculation, for every frame from start to current time, you need to calculate the rotation.

You may find that instead of having script controllers, you might need to write a script that runs through your timeline and sets keys on your objects.

I’ll put together a quick maxfile demonstrating this and send it through later.

http://home.iprimus.com.au/wickergray/cogs.max
Let this run to the end to see that only one cog being driven like this with a script controller will slow your scene down. Imagine a bunch of them.

Hello, Thanks, I’m curently ultra-busy… I got the scene, i’ll take a look very soon.

Many thanks…

No answer, on any forum.

Maybe there is another way to achieve that setup. And you can help me because I’m not qualified enough for scripting.

With a float script is there a way to control gear2 by evaluating the difference between frame X and Frame X-1 ???

I want something like this :

  1. Evaluating G1 rotation between current frame and previous frame

(ex: rotation G1 at frame 20 – rotation G1 at frame 19)

  1. if G1 rotation >= 0 then g2.rotation = g1.rotation else 0

Hope to be clear this time.

Hope someone can help…

No you can’t calculate it like that, cause as I said, frame X-1 depends on what’s happened in the frames before that so unless you’re setting keys on an object as you go, the rotation of the cog at frame X-1 won’t be in the right spot to start with. So there’s 2 ways you can go about this other than the computationally expensive way that you asked to start with.

You can use a script to run through time setting keys on your object based on whether the other cog is rotating forward. This way you know where the cog is at X-1 cause it’s been calculated and set beforehand.

OR there’s another way that is linear based that you can use a script float. Every part of your watch that you want to animate should be driven by either a time value or another object that you just rotate at a constant speed. I’ll post a maxfile later if I get a chance.

Cg.

In the following file, there are 3 cogs.

Driver: The Y rotation value in this cog drives everything. There is also an attribute holder modifier on this object to set the “cycle” The cycle is to define how the driven cog’s rotation relate to the driver. So when it’s set to 45, the driven cogs will complete a cycle of their motion for every 45 degrees that the driver rotates.

Driven1: Rotates back and forth through the cycle
Driven2: Rotates forward for half of the time of the cycle.

There are explanations of the script controllers inside them.

The driver’s rotation must stay in positive or won’t work properly. The script controllers could be modified to account for that, but that will just start to make them more complicated and harder to understand for someone that’s not accustomed to scripting.

http://home.iprimus.com.au/wickergray/cogs_better.max

Paul just posted a tutorial for this:
http://penproductions.ca/tutorials/gears/gears.html

Even though Paul’s tutorial is very good as his tutorials always are, it doesn’t cover the original poster’s question.