{"id":1400,"date":"2012-11-04T03:22:18","date_gmt":"2012-11-04T01:22:18","guid":{"rendered":"http:\/\/www.smart-page.net\/blog\/?p=1400"},"modified":"2012-11-04T06:46:00","modified_gmt":"2012-11-04T04:46:00","slug":"python-cinema-4d-api-auto-completion-fake-modules","status":"publish","type":"post","link":"http:\/\/www.smart-page.net\/blog\/2012\/11\/04\/python-cinema-4d-api-auto-completion-fake-modules\/","title":{"rendered":"Python Cinema 4D API auto completion (fake package)"},"content":{"rendered":"<p>The combination of Eclipse and PyDev makes an excellent development environment for coding Cinema 4D python plugins.<br \/>\nSadly, there was this one &#8211; major &#8211; feature of PyDev I just couldn\u2019t get to work&#8230; completions.<\/p>\n<p>And that was a shame, because this is probably the most awesome feature of PyDev and speeds things up a lot.<\/p>\n<p><strong>Now it&#8217;s finally usable!<\/strong> (well&#8230; mostly)<\/p>\n<p><!--more--><\/p>\n<p><\/p>\n<h3>Why?<\/h3>\n<p>And there was this other issue&#8230; since your interpreter and PyDev know nothing of the Cinema 4D API, PyDev marks every import and call as error.<\/p>\n<p>Before long, you don&#8217;t even bother looking at the &#8216;Problems&#8217;-tab anymore &#8211; there&#8217;s just errors everywhere!<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1403\" title=\"sep0\" src=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep0.jpg\" alt=\"\" width=\"683\" height=\"70\" srcset=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep0.jpg 683w, http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep0-300x30.jpg 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><br \/>\n<br \/>\nIf 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.<br \/>\n<\/p>\n<h3>How?<\/h3>\n<p>After some failed tries, I finally managed to pull most of what I needed from the API via introspection:<br \/>\nattributes, classes, methods&#8230;<\/p>\n<p>What I didn&#8217;t manage to extract are method arguments &#8211; sorry, it just can&#8217;t be done that way&#8230;<br \/>\n<br \/>\nBut still this is way better than nothing or what I had initially hoped for &#8211; I ended up with a neat little fake &#8216;c4d&#8217; package including all sub modules.<\/p>\n<p>I moved it to the <em>&#8216;\/Libs\/site-packages\/&#8217;<\/em> folder of my external interpreter (DONT! try that with the Cinema 4D interpreter &#8211; just install a second), fired up Eclipse&#8230; opened a fairly complex plugin project&#8230; and b\u00e4m! no errors &#8211; working auto completion &#8211; happiness!<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1414\" title=\"sep2\" src=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep2.jpg\" alt=\"\" width=\"683\" height=\"85\" srcset=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep2.jpg 683w, http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/11\/sep2-300x37.jpg 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><br \/>\n<br \/>\nOh and the best part? This should work with any other python IDE that do not rely on predefined completion libraries.<br \/>\n<\/p>\n<h3>Where?<\/h3>\n<p>So I updated the <a href=\"http:\/\/www.smart-page.net\/blog\/2011\/05\/09\/advanced-python-plugin-coding-for-cinema-4d\/\" target=\"_blank\">Advanced Python plugin coding for Cinema 4D post<\/a> (that will help you to setup your Eclipse+PyDev developing environment &#8211; if you don&#8217;t already use one, just head over) accordingly and uploaded the package&#8230;<\/p>\n<p><\/p>\n<p><strong>-> <a href=\"http:\/\/www.smart-page.net\/python\/c4d_fake_package.zip\">You can grab the fake package here!<\/a> <-<\/strong><br \/>\n<\/p>\n<h3>But hear me out first!<\/h3>\n<p><strong>There is some disclaimer stuff that I would really like you to read before you use it:<\/strong><br \/>\n<\/p>\n<ul>\n<li>These are FAKE! modules &#8211; they may <strong>N E V E R<\/strong> go out into the wild &#8211; please make really sure you don&#8217;t accidently ship them with your plugin etc.<\/li>\n<p><\/p>\n<li>Everything is extracted from the Cinema 4D R14.025 Python API &#8211; if you use any other build, you might\/will see inconsistencies. I would supply the script to extract them but it&#8217;s not that simple, a good deal of manual labour went into this&#8230;<\/li>\n<p><\/p>\n<li>This is slapped together with a lot of tape, voodoo, coffee and good intentions &#8211; I am sure there are a lot of areas where I messed up, so <strong>A L W A Y S<\/strong> (sry 4 caps lock) make sure you use the documentation.<br \/>\n<strong>N E V E R<\/strong> rely on the docstings of these modules.<\/li>\n<\/ul>\n<p><\/p>\n<p>Have fun coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The combination of Eclipse and PyDev makes an excellent development environment for coding Cinema 4D python plugins. Sadly, there was this one &#8211; major &#8211; feature of PyDev I just couldn\u2019t get to work&#8230; completions. And that was a shame, because this is probably the most awesome feature of PyDev and speeds things up a lot. Now it&#8217;s finally usable! (well&#8230; mostly)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[52,53,1,88],"tags":[188,180,189,190,181],"_links":{"self":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1400"}],"collection":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/comments?post=1400"}],"version-history":[{"count":44,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions"}],"predecessor-version":[{"id":1451,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions\/1451"}],"wp:attachment":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/media?parent=1400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/categories?post=1400"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/tags?post=1400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}