{"id":1897,"date":"2018-09-22T20:05:39","date_gmt":"2018-09-22T18:05:39","guid":{"rendered":"http:\/\/www.phreekz.de\/wordpress\/?p=1897"},"modified":"2018-09-22T20:05:39","modified_gmt":"2018-09-22T18:05:39","slug":"3dsmax-python-json-example","status":"publish","type":"post","link":"http:\/\/www.phreekz.de\/wordpress\/2018\/09\/3dsmax-python-json-example\/","title":{"rendered":"3dsmax python json example"},"content":{"rendered":"<p>Kurz und b\u00fcndig: Eine Liste an Daten, vorgegeben als json, soll in 3dsmax zu Objekteigenschaften benutzt werden. In meinem Fall <a href=\"https:\/\/api.coindesk.com\/v1\/bpi\/historical\/close.json?start=2012-01-01&#038;end=2018-01-01\">historische Bitcoin-Daten (2012 bis 2017, zB bei coindesk zu finden)<\/a>, welche die H\u00f6he der Boxes vorgeben.<\/p>\n<p>1. Wie lade ich json-Daten in 3dsmax<br \/>\n2. wie erstelle ich Objekte mit gewissen Eigenschaften.<\/p>\n<pre lang=\"python\">\r\nimport json\r\n\r\nmDays = [31,28,31,30,31,30,31,31,30,31,30,31]\r\n\r\n# -- loading json is simple --\r\n# -- take link above for according json-file\r\n\r\nfileIN = open(\"c:\/path\/to\/your\/file\/bitcoin_historical.json\",\"r\")\r\npythonData = json.loads(fileIN.read())\r\nfileIN.close()\r\n\r\n# -- now reading json data\r\n# -- then creating box\r\n# --> reading all values of a month and averaging them\r\n# --> creating only box per month\r\n\r\npositionX = 0\r\nfor year in range(2012,2018):\r\n    for month in range(12):\r\n        mo = str(month+1).zfill(2)\r\n        avgVal = 0\r\n        for day in range(mDays[month]):\r\n            dy = str(day+1).zfill(2)\r\n            sKey = str(year)+\"-\"+mo+\"-\"+dy\r\n            avgVal += pythonData['bpi'][sKey]\r\n            #print sKey, \"=>\",pythonData['bpi'][sKey]\r\n        avgVal = avgVal\/mDays[month]\r\n        obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Box)\r\n        obj.ParameterBlock.Width.Value = 20\r\n        obj.ParameterBlock.Length.Value = 20\r\n        obj.ParameterBlock.Height.Value = avgVal\r\n        node = MaxPlus.Factory.CreateNode(obj)\r\n        node.Position = MaxPlus.Point3(positionX, 0, 0)\r\n        node.Name = str(year)+\"-\"+mo\r\n        positionX = positionX +40\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Kurz und b\u00fcndig: Eine Liste an Daten, vorgegeben als json, soll in 3dsmax zu Objekteigenschaften benutzt werden. In meinem Fall historische Bitcoin-Daten (2012 bis 2017, zB bei coindesk zu finden), welche die H\u00f6he der Boxes vorgeben. 1. Wie lade ich json-Daten in 3dsmax 2. wie erstelle ich Objekte mit gewissen Eigenschaften. import json mDays =&hellip; <a class=\"more-link\" href=\"http:\/\/www.phreekz.de\/wordpress\/2018\/09\/3dsmax-python-json-example\/\"><span class=\"screen-reader-text\">3dsmax python json example<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[405,401,404,406,402,403,258],"class_list":["post-1897","post","type-post","status-publish","format-standard","hentry","category-pc-leben-und-leiden","tag-3d","tag-3dsmax","tag-bitcoin","tag-example","tag-json","tag-maxscript","tag-python","entry"],"_links":{"self":[{"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/1897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/comments?post=1897"}],"version-history":[{"count":4,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/1897\/revisions"}],"predecessor-version":[{"id":1901,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/1897\/revisions\/1901"}],"wp:attachment":[{"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/media?parent=1897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/categories?post=1897"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/tags?post=1897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}