{"id":1368,"date":"2012-06-24T23:21:25","date_gmt":"2012-06-24T21:21:25","guid":{"rendered":"http:\/\/www.smart-page.net\/blog\/?p=1368"},"modified":"2012-06-24T23:25:23","modified_gmt":"2012-06-24T21:25:23","slug":"smart-polychart-cinema-4d-plugin-fun-with-the-userarea","status":"publish","type":"post","link":"http:\/\/www.smart-page.net\/blog\/2012\/06\/24\/smart-polychart-cinema-4d-plugin-fun-with-the-userarea\/","title":{"rendered":"Smart PolyChart Cinema 4D Plugin &#8211; fun with the UserArea"},"content":{"rendered":"<p>Smart PolyChart is a simple CommandData plugin which draws a neat bar chart from the polygon counts of all polygon objects in a scene.<\/p>\n<p><a href=\"http:\/\/www.smart-page.net\/py4d\/SmartPolyChart.zip\">You can download it here<\/a> &#8211; the source is documented.<br \/>\n<\/p>\n<h2>The part for users:<\/h2>\n<p>Just drag it into your <em>\/Plugins<\/em> folder and open it from the <em>&#8216;Plugins&#8217;<\/em> menu. The <em>&#8216;Update&#8217;<\/em> button refreshes the view, a click on a column will select the corresponding object so you can optimize or remove it to lower the scenes polygon count.<br \/>\n<br \/>\n<!--more--><br \/>\n<\/p>\n<h2>The part for coders:<\/h2>\n<p>Why another CommandData Plugin? Well, I thought this one might actually be helpful for some users and a great excuse to have a little fun with the UserArea.<\/p>\n<p>The UserArea is a Gadget that allows you to draw bitmaps, lines, etc. onto a canvas &#8211; and lets the user interact with them.<\/p>\n<p>Since the <a href=\"http:\/\/www.smart-page.net\/blog\/2012\/02\/22\/smart-hn-options-cinema-4d-python-commanddata-plugin-template\/\" target=\"_blank\">previous post<\/a> completed the little &#8216;advanced python plugin coding trilogy&#8217; with a CommandData plugin, I don&#8217;t have to go into too much detail about the projects structure.<\/p>\n<p>Just a quick note about the <em>&#8216;worker.py&#8217;<\/em> &#8211; the code in that file just recourses through the documents to find all polygon type objects and return a list of them.<br \/>\nIi could well have been a part of the <em>&#8216;maindialog.py&#8217;<\/em> or the <em>&#8216;canvas.py&#8217;<\/em> itself &#8211; but same as with the previous plugin, I kept it speparate.<\/p>\n<p>Only a reminder that not everything has to be a class or included within the classes you extend from the Cinema4D API.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/06\/grayscale1.jpg\" alt=\"\" title=\"grayscale\" width=\"683\" height=\"70\" class=\"alignleft size-full wp-image-1387\" srcset=\"http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/06\/grayscale1.jpg 683w, http:\/\/www.smart-page.net\/blog\/wp-content\/uploads\/2012\/06\/grayscale1-300x30.jpg 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><br \/>\nIf you take a look at the <em>&#8216;canvas.py&#8217;<\/em> and already have some 2D-drawing experience, you&#8217;ll find it pretty straight forward.<\/p>\n<p>Just remember to set the clipping region to the area of the canvas you currently want to draw in.<\/p>\n<p>Redrawing the whole canvas for every update is a bad practice &#8211; at least if you want to frequently update or even animate something.<\/p>\n<p>Due to the nature of the graphic the plugin produces (a bunch of bars most times filling the complete &#8216;screen&#8217; or workspace), there is little to be gained here by calling <code>SetClippingRegion()<\/code> &#8211; but it&#8217;s still used to keep the text elements from overlapping the outlines.<\/p>\n<p>Still, it&#8217;s a good habit to look for parts of the canvas you can just leave alone in a following update &#8211; clip and re-draw only what needs to be changed.<\/p>\n<p>The source also holds a little example on how to handle mouse events within a UserArea &#8211; keep in mind that the mouse coordinates need to be offset by the position of the gadget on the screen.<br \/>\n<\/p>\n<h2>return<\/h2>\n<p>Trying to keep it short this time&#8230; &#8211; hope you have fun coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Smart PolyChart is a simple CommandData plugin which draws a neat bar chart from the polygon counts of all polygon objects in a scene. You can download it here &#8211; the source is documented. The part for users: Just drag it into your \/Plugins folder and open it from the &#8216;Plugins&#8217; menu. The &#8216;Update&#8217; button refreshes the view, a click on a column will select &hellip; <a href=\"http:\/\/www.smart-page.net\/blog\/2012\/06\/24\/smart-polychart-cinema-4d-plugin-fun-with-the-userarea\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Smart PolyChart Cinema 4D Plugin &#8211; fun with the UserArea<\/span> <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[52,53,88],"tags":[186,187,177],"_links":{"self":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1368"}],"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=1368"}],"version-history":[{"count":26,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1368\/revisions"}],"predecessor-version":[{"id":1396,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/posts\/1368\/revisions\/1396"}],"wp:attachment":[{"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/media?parent=1368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/categories?post=1368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.smart-page.net\/blog\/wp-json\/wp\/v2\/tags?post=1368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}