# Creating Geometry With Python In C4D

Free Tutorials

HI people from the internet. After posting my geometry creation tutorial for Houdini, people approached me with the question, if such a plexus effect is possible in Cinema 4D, too. And I said no, not without plugins. But after thinking about it for a little while, I found a solution to do this with Cinema4D off-the-shelf tools. I’m using the ParticlePassAB node to find the closest points and Python to create the geometry. So if you’re interested in having a closer look on an old but powerful TP feature, this tutorial is for you.

You don’t have to rely on this technique though, if you’re just after the results. There are plugins, even free ones, out there doing just this effect. One of them is the UberTracer by Gene Magtoto, that you can download here: https://www.genemagtoto.com/c4dplugins/

1. Great Stuff!
I was thinking of doing the same thing in Python but couldn’t think of an easy way of getting the closest points, but this seems to be the way to go!

And I believe it should also be possible to automate the Connect + Delete step by putting all splines into a Connect Object and collapse it within Python. Or do you know of another way of adding segments to a Spline?

• Manuel

Hi Florian,

the problem with the connect object is probably that it’ll take a long time to connect all the splines. Other than that it’ll work. It’s of course possible to add segments to a spline directly. You can do so by calling ResizeObject() after the spline creation and tell it how many segments it should have. Then you’ll use SetSegment() to set the individual segments. The problem with the setup from the tutorial is that you are inside of a Xpresso iteration. And that means you don’t know the segment information at any given time. What you would want to do is to write the closest point information to a sequential string attribute. This can be used in a python generator to create the splines afterwards. This would allow for removing the doubles as a side effect.

Hope this helps, cheers mnu

2. Hi Manuel,

Firstly, great tutorial. However I have hit a snag.

Everything seemed to be working fine but once I had added all of the data into the Python Editor then nothing seems to happen.

I have actually run through the tutorial twice now to double check to see if I had made a simple mistake along the way. Is there any way you would be able to look at my file to see if there is something simple I have done wrong? Then if there is anything I could do to repay the favour I would be happy to, a collaboration perhaps?

Many thanks
Craig

• Manuel

Hi Craig, send it to mail[at]entagma[dot]com and I will have a look if my time allows.

3. Reto Christiani from C.biz

Danke Manuel for making me a bit smarter today!
well explained and snatched more from my Python restraint!
also took just a couple more steps to create a rig and replacing all kinds of plugins.

• Manuel

Sounds cool. Do you want to share?

• Reto Christiani from C.biz

just careful with the number of points and distance you’ll set! danger to freeze your machine! ; )

to improve the rig further I’m still trying to figure out a way to select all Splines in the Geo-Null, connect and delete them to make life even easier …

4. hi, great tutorial, but I am making mistakes, any chance for a sample scene file please?, thank you in advance,Craig

5. Matt White

I can’t quite get it to work.

I see you created a second particle group but can’t see where you used it.

• Manuel

The second particle group was left over from some previous experiments accidentally, and was not used in the setup.

6. Nils Denon

Hi Manuel,

Thanks for this great tutorial! Unfortunately like Craig I did this tutorial two times and I am also not getting any network of splines. Splines are being generated but they all have the same position.
I double checked the python but found no errors and the console doesn’t throw any…

Would you be so kind and either check my File or provide a working example?

https://www.dropbox.com/s/dusjrnicty412v9/pythonGeometry.c4d?dl=0

• Manuel

I will upload an example file asap.

7. Manuel

I’ve added a demo scene above.

8. Nils Denon

Thanks a lot Manuel! I can’t wait to see new tutorials from you guys!

9. Jose Ponce

Thank you for the great tutorial, I haven’t worked much with xpresso or python within c4d, and was still able to follow along and understand the process.

I was just wondering if you might be able to suggest a natural looking method of animating the growth of the sweep from a single point of origin across the whole object? Currently animating the sweep results in a spread out growth from all the individual particle points. The only other thing I can think of is converting to object and using a boole or using an animated black and white texture as a matte across the object.

Thank you again

10. Not working, unfortunately, and neither is your example scene…

11. I think I posted a comment before saying that everything ran perfectly…. but anyways I would like to thank you again for the tutorial, I am not myself very good with xpresso neither python because I am not good at them but I am curious on how they work, this tut it´s a very good start to learn and understand both, I enjoyed a lot and it triggered some interesting ideas, too powerful. Thanks a lot! you can check the results on my website.
Take care guys!
http://www.kumo-z.com

12. Thanks so much for this tutorial! Am really keen to use xpresso more but tutorials seem to be like gold dust. This was really easy to follow and informative about what the different nodes were for.

I was getting a “frame not defined” error when I tried to run the script. If anyone else is having that problem, this change to the python code solved the issue for me:

def main():
FPS= doc.GetFps()
time= doc.GetTime()
current_frame= time.GetFrame(FPS)

if current_frame ==1:

…then continue with the script as shown.

13. Hi Manuel, excellent tutorial. I’m having trouble rendering the files in Octane the Standard renderer seems to work fine. Is there any tips to minimize the geo? Thanks for the shared knowledge!