[SOLVED] I wonder – is there a better way to "follow a cam?"

Here’s something that I have to do a lot: “model a piece of antique machinery whose equipment is driven by a cam.” It is oddly-shaped, sometimes a disc but sometimes three-dimensional. And, right now, I’m having to carefully set up actions. But, I wonder if there might be a better way for me. (Blender 2.8, and I’m a fluent Python programmer …) Yes, I’m willing to invest some time into a better solution.

What I’d like to be able to do is to trace a three-dimensional curve, bound (parented?) to the cam, which describes the exact path which should be followed around the cam by some “follower.” Then, I would specify the follower, and indicate which of its local axes is the one around which it is free to rotate. Then, I’d probably designate an Empty, parented to the follower, which describes the point of contact.

Of course, one reasonable solution would then be to “bake an Action,” doing so automagically.

Another approach would be procedural.

One factor in favor of a “procedural” approach is that I really want to specify only the rotation of the shaft, and to have everything else follow-suit even when the shaft rotates backwards or stops. Another is that “shafts sometimes drive other shafts,” so a procedural solution would have to somehow cascade.


If I’m understanding what you are looking for, I think your best bet before getting into scripting stuff, would be to use the shrinkwrap constraint, while locking the “follower” to a single axis of travel.


Yippeee!!:bulb: … I don’t think you comprehend just how much time [I think …] you just saved me. :kiss:

I had totally overlooked this constraint. (In fact, I now realize that I haven’t been paying attention to "rigging constraints" in general.)

Now, if I may indulge you, let me elaborate on a couple of other points, just to be sure (while I’m reading documentation!)

  1. Many of the camshafts in question were “magnificent castings,” with very complex shapes that were followed by more than one part, most of which were levers. In other words, they rotate in response to the influence exerted by the cam. I’m visualizing the need for maybe an Empty here, to serve as the actual “follower.” But I need to be sure that I know how to then cause the lever to rotate back-and-forth as though it were “pushed” by that empty. (TrackTo, maybe?)

  2. Some of those levers then “did other things,” creating a chain of movements which were originally driven by the cam-follower. Can I use constraints once again to somehow describe that chain of motions?

Mind you, I’m still reading an entire section of documentation that – somehow – I see that I had overlooked. Thanks for your further insights.

(P.S.: It’s perfectly okay if you reply to me … “Bones.”)

I’m reading … I’m reading … :smiley:

P.S.: "Still the most fun aspect of this crazy biz is that you’re always learning something new – quite often, “the hard way.” :roll_eyes: Sometimes it’s actually a bit of a dis- advantage if you’ve been using the product as long as I have. Stuff changes and gets added right under your nose, and, “are you watching closely?”:mage:

Absolutely! After 15 years, I still feel like a newbie at times, constantly having to keep up with tricks the new kids are coming up with. It’s good though. Keeps things from becoming boring and monotonous.

Back to your question; I don’t know what antique machinery you are working with. However, I’m familiar with cars, and what you describe sounds like an overhead valve system, where the cam hits a pushrod, which rotates a rocker, translating the linear motion in another direction.

There are three ways I can think of to do this:

  • Using IK constraints to drive a chain of bones. (Seems too fiddly.)
  • Using a series of transform constraints. > rotation (cam) to linear (pushrod) to rotation (rocker) to linear (valve) (Too much math for adapting to other systems easily)
  • Or what I did in this example:
    • Pushrod has the Shrinkwrap constraint.
    • Rocker has a Locked Track constraint (Targeting Pushrod’s tail)
    • Valve has a CopyLoc constraint (Targeting Pushrod).
    • All constraints are in local space, and parented to the bones in the Framing bone group. This allows you to easily change the length and angle of attack on the parts. You could also adapt it to a system where the cam pushes on the rocker directly.

cam.blend (133.3 KB)

Actually, the present machine is a railroad spike machine as described in Burden’s US patent #1757 issued on Sept. 2, 1840. In a single rotation, the machine forms the spike, bends down (“upsets”) the top of the bar – this was Burden’s key improvement – then forms the spike and ejects it. The camshaft which drives the various movements of the machine looks like this:


And, to really figure out how the damned thing works (since the associated museum exhibit doesn’t move), I’ve had to reconstruct the movements using animation, rotating the shaft and observing how the followers trigger each motion. I’m also using these methods to look at it “from a red-hot iron bar’s point of view” to see exactly how it forms and then ejects a spike. There are four major cam-driven motions, precisely timed,

It promises to be very helpful to let Blender do the following because I then have only one thing to rotate: the shaft itself. All of the subsequent motions will be driven by the shaft, just as in real life.

Sounds interesting… And quite complicated. The .blend I posted above should still be adaptable to this. A cam is either pressing on a rod, or a lever/rocker and that rig will work in either case, and with any cam shape. I’d go the extra distance, but I start charging at the one hour mark. :stuck_out_tongue:

Anyway, post an animation once you’ve got it figured out. Would be interesting to see.

Of course you don’t need to do that. I’ve got the animation “running” but laboriously because I keyframed each part.

It looks like the follow-strategy will work. (The various levers can then “point to” that follower empty.) This will also more-easily point out if I made any errors in my keyframing. The only movement that I’m still a little puzzled-about is the movement of the leftmost piece: that great big piece of iron is one of the two dies that forms the spike, and it rotates on the X-axis, “flopping” to the left to open, then being forced to the right to close upon the red-hot piece of stock. The others are straightforward levers: the upsetter, the head-forming die, and a cutter/ejector.

I really can’t tell what’s going on in that image. Do you have any other angles?

I remember having a possible solution to this problem posted in some other thread. (Was an old one, as it was originally started when shrink-wrap wasn’t an option for armatures. So I added on showing the new trick some time after the update came out. Otherwise you had to go crazy with drivers for any accuracy.)

There’s leading and following bones that compensate for a more eccentric cam offset, as a single shrink wrap constrained bone alone doesn’t allow much for interference. Still feels a bit of a kludge, yet more workable.

CamFollowerTest.blend (533.3 KB)

1 Like

That’s the method I suggested above, but I do like the idea of the leading and following bones for additional accuracy. :+1:

It’s sort of needed for any close-up views because bones only have one point of contact for this particular constraint. Otherwise if you have a wider surface being “pushed” by the cam (not exactly, since it’s the rig doing its thing), the contacting surfaces will go through each other. And keep in mind those would need adjusting for a different shaped cam profile or different shaped cam follower.

Since I do need to “follow a curve” on this animation … one of the pieces “flops to one side” as directed by a cam that has a diagonal slice taken out of it … I have also been wondering if I could use 3D curves. I would parent this curve to the cam, and have (say) an Empty follow it … then specify different rotations along the path. The Empty could be made to progress around the path in time with the rotation of the part. (Hand-waving now … “somehow.”) :thinking:

Hey, I know for me, when it comes to machinery animation, especially that repetitive stuff that doesn’t change much if any - action constraint - its saved me plenty of times. Just sayin…

The problem with this approach (if automation is still the goal) is that the motion along the curve wouldn’t be linear. So you’d be spending some time fiddling with animation curves.

What I’d do is create an edge loop down the center of the track on the cam and isolate it into it’s own object. Divide this edge loop a few times so the vertices are fairly dense. This is your curve to be followed. As before, use the shrinkwrap constraint but set to nearest vertex mode.

If needed, I can illustrate this when I’m at a computer in a few hours.

You didn’t ask for it, but I can’t seem to help myself. haha I find mechanical stuff like this interesting, but it’s outside of my typical area of work. Anyway, the shrinkwrap “path” works, but it is hacky.

Here’s how it looks:

Here’s how it’s hacky:

Yeah… :smile: As the shrinkwrap constraint doesn’t have a sub-frame sampling feature, it has a hard time keeping up with the cam’s motion. You can fix this by “sampling” the path object multiple times.

Yep, been there too my friend! :smiley:

I have just seen this thread and I have to say this is exactly (I think) how I do this, minor mod to what you have done is that I do this:

  1. Create the cam profile as a Bezier Curve - set Resolution to 128
  2. Convert to mesh ALT+C.
  3. Add FOUR Shrink-wraps and Limit Locations like this:

Shrink-wraps are set to “Nearest Vertex”.

Rotate the path object and the bone stays very, very, very close!

The resolution and the number of constraints is determined by how accurately you want the bone to stick to the path.

Cheers, Clock. :beers:


Holy shit! I tried this some years ago, it is very difficult to get the timings for rotation and path location right…

Here’s a quick blend file to play with. With the “Empty” solution on the left, I just scaled the Key-Frames so the Empty movement matched the cam (yes cheating I know), but it is quick and easy to do.

Blend File, cam-1.blend (505.2 KB)

  • just press Play…

The “Bone” solution is very quickly thrown together and the cam is not very accurate…

Cheers, Clock. :beers:

Wow, that’s a lot to chew on.

The only problem I’m having right now, vis a’ vis egCody’s most-recent reply, is that one piece of the machine actually rotates on its Z-axis, being forced to rotate by a follower that rests upon the cam. So, the motion imparted by the cam is not linear, but rotational. I’m still having a bit of a problem with that one.

But: “wow, thanks, folks!” :slight_smile:

1 Like

Simple enough addition; Just add an additional bone at the pivot point of this rotating arm with a damped track to the follower (or vise versa - damped track on the follower, targeting the additional bone).