Align to Spline Tag doesn't work with Spline created in Python Generator? What do I do?


I’m using the Python generator to create a spline, but for some reason the “Align to Spline” tag doesn’t seem to work with it. I’m guessing it’s because I’m not generating the spline in the python generator properly, but I’m not sure. I have it set up like this:

What do I need to change to get the align to spline tag to work properly? I want to animate the cone moving along the spline at the head of the sweep (so it looks like an arrow randomly moving up and down). I have attached my R19 scene file below for reference:
random stock walk.c4d (264.2 KB)


try adding a mospine to the scene, set it from simple to spline, then try dropping the generated spline into the referecne field. MAke sure the python spline is above the mospline in the OM heirarchy. The mospline should be an exact replica of the python spline. Try isong align to spline on the mospline instead.


I’ve made some changes that pretty much gets what you want.
Still needs adjustment …

ATS.c4d (134.7 KB)


The Python Generator can not create splines. At least not in a fully compatible way. The thing is, in order to correctly create splines, you need to register an Object Generator plugin with a special flag set. This flag can not be changed during run time, only during plugin registration (lets say program start). The Python Generator is exactly this, an Object Generator plugin, but thought to create objects, so it does not have this needed flag set. Using the Python Generator you can come close, but you will never get there a hundred percent. And then it depends, how other entities making use of splines try to acquire such. if they simply use the documented way, they will usually fail on splines “faked” by the Python Generator.


@JoelDubin, unfortunately, this doesn’t seem to do anything. The mospline doesn’t even show up:


@vid2k2, it seems that making it editable makes it work, but why? I don’t understand why this is necessary.

@MighT42, I don’t know what you mean by “register an Object Generator plugin with a special flag set”. Can you please explain how I would do this?


Yeah it appears that the generated spline is not generated in a way that any other tool in c4d can recognize it as such (unless its made editable). I tried running clones on each vertex point too thinking that I can use the tracer object to re generate a new spline from the cloner–but the cloner doesnt see it.

Looks like you might need to edit the python script as MighT42 suggests?


Solved it. I used a Tracer object. In your Cone’s Align to Spline tag use the Tracer as your Spline Path.


Why editable … as noted above …python generator isn’t a spline in the true
sense. So, making it a type of spline made it all work … even though I simplified
the scene.


I tried to say, you can’t do anything and I did not want to imply you could change this by editing the Python code of the Generator. A Python Generator can not create proper splines.
Thus @nimpsy’s workaround, where the Tracer creates the actual spline.

Not sure, I can explain it properly. It may sound strange, if you have no experience in plugin development for C4D. Please forgive, if I fail…

Basically every parametric object is a certain type of plugin. In the SDK/API these are called ObjectData or lets call them Object Generators. There are different flavors of Object Generators, for example for mesh objects (i.e. Cube or Sphere objects) or like it would be needed here splines. All plugins get registered within C4D during startup via a special register function. This register function has a parameter which defines the flavor, which is then fixed during the life time of the plugin (aka the run time of C4D). So, the flavor is a decision of the plugin developer and it can not be changed during run time. The Python Generator is just this, a Object Generator with “mesh flavor”, which makes use of the user’s Python code to generate an actual mesh. And that’s basically it. There is no Python Generator with spline flavor. And there’s no way this could be changed by the user.
So, if you use the Python Generator to create a spline, like you did, you are actually doing something not really defined. The result is a strange hybrid of a spline and a mesh object, which not many places in C4D are able to interpret correctly as a spline.

You’d need to ask Maxon for a Python Spline Generator. Or you could look for a plugin developer to develop it for you. If you should be interested, you are welcome to PM me.