Python Cinema 4D API auto completion (fake package)

The combination of Eclipse and PyDev makes an excellent development environment for coding Cinema 4D python plugins.
Sadly, there was this one – major – feature of PyDev I just couldn’t get to work… completions.

And that was a shame, because this is probably the most awesome feature of PyDev and speeds things up a lot.

Now it’s finally usable! (well… mostly)

Why?

And there was this other issue… since your interpreter and PyDev know nothing of the Cinema 4D API, PyDev marks every import and call as error.

Before long, you don’t even bother looking at the ‘Problems’-tab anymore – there’s just errors everywhere!



If that feature was working, it would greatly reduce the number of plugin-reloads or Cinema 4D restarts as one would be able to catch many typos, syntax errors and alike before actually executing the code.

How?

After some failed tries, I finally managed to pull most of what I needed from the API via introspection:
attributes, classes, methods…

What I didn’t manage to extract are method arguments – sorry, it just can’t be done that way…

But still this is way better than nothing or what I had initially hoped for – I ended up with a neat little fake ‘c4d’ package including all sub modules.

I moved it to the ‘/Libs/site-packages/’ folder of my external interpreter (DONT! try that with the Cinema 4D interpreter – just install a second), fired up Eclipse… opened a fairly complex plugin project… and bäm! no errors – working auto completion – happiness!



Oh and the best part? This should work with any other python IDE that do not rely on predefined completion libraries.

Where?

So I updated the Advanced Python plugin coding for Cinema 4D post (that will help you to setup your Eclipse+PyDev developing environment – if you don’t already use one, just head over) accordingly and uploaded the package…

-> You can grab the fake package here! <-

But hear me out first!

There is some disclaimer stuff that I would really like you to read before you use it:

  • These are FAKE! modules – they may N E V E R go out into the wild – please make really sure you don’t accidently ship them with your plugin etc.
  • Everything is extracted from the Cinema 4D R14.025 Python API – if you use any other build, you might/will see inconsistencies. I would supply the script to extract them but it’s not that simple, a good deal of manual labour went into this…
  • This is slapped together with a lot of tape, voodoo, coffee and good intentions – I am sure there are a lot of areas where I messed up, so A L W A Y S (sry 4 caps lock) make sure you use the documentation.
    N E V E R rely on the docstings of these modules.

Have fun coding!

3 thoughts on “Python Cinema 4D API auto completion (fake package)”

    1. flashgordon Post Author

      Not that silly 🙂

      Meaning that it will work in your IDE, but you will be missing all new API features since I build the package – also please keep in mind that you can’t trust your IDE’s suggestions 100% (which you shouldn’t in any case)

      Maybe I will find the time to update it now what R17 is out… until then – by any means – give it a go! 🙂

      Cheers

  1. Anonymous

    Or better you make it directly for R18 now 😉

    But now in earnest it really would be cool to have a more up-to-date version of this package.
    There had been a lot of changes since R14 meanwhile.

    I even thought about doing it myself but a closer look showed me that it would indeed be a real nightmare hacking it together manually.

    I guess you used Pythons own “inspect” module for solving this task, am I right?

    Maybe I’ll actually give it a try once if you don’t want to do it yourself.
    But that’ll also take quite a while for sure till I find the time to figure it out myself.

    Kind regards,
    Tom

Leave a Reply to flashgordon Cancel Reply

Your email address will not be published.