Can I assume that the Fancy cube is a 3D render that is now 2D footage? When you bring that footage into AE, it has no knowledge of depth so any layers you put on top of that layer will land in front and any layers you put behind will be obscured by the cube’s alpha – even if those “in front” and “behind” layers are 3D solid layers. So putting the Red Solid on top, even though its a 3D layer, means it can’t “go behind” the cube’s flat render because there isn’t really any behind to go to. You can think of it as : when you add a 2D layer (or an adjustment layer) into a 3D AE scene, wherever that 2D layer is in the stack AE flattens all the layers below and renders them along with that 2D layer on a 2D plane that sits at level 0. Any 3D layers above that layer start the 3D stack again with that newly rendered “flat” behind them.
So a couple of options.
You can split the Solid layer (cntl/shiftD), or whatever you are replacing the solid with- one for behind(below) and one for the front (on top) of the 2D render of the cube, and use the cube’s alpha as a track matte for the one that sits behind (below). The top solid can just render on top and obscure the cube when it needs to and the behind one will be obscured by the cubes matte when it passes underneath. But that doesn’t always work since the solid can be partially obscured itself AND partially obscure the cube at the same time. You can also get ringing when the solid is edge on – even though its a 3D layer it has no z depth itself – its flat flat flat.
You could render out a depth map or a position map of of the scene in C4D and use one of the 3D effects in AE to mask the solid based on the depth information.This isn’t always the best and has some issues. You also need to render and comp in a high bit depth (not the same depth as the depth map) so that all the subtle differences in geometric depth can be captured.
You could use the track matte idea from the first solution and hand mask another layer of the solid in for spots where it both ends up behind and in front on the same frame.
I’m assuming you want to replace the solid with some other footage or you would have just rendered the whole thing in C4D and be done. Like an image that rotates about the cube?
You could use the cineware tools (or the C4D plug in if you are an older version of AE) and have the cube rendered from within After Effects. Then its truly 3D in the scene and the z position of the red solid is honored as it rotates in front and behind.