Kurz und bündig: 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öhe der Boxes vorgeben.
1. Wie lade ich json-Daten in 3dsmax
2. wie erstelle ich Objekte mit gewissen Eigenschaften.
import json mDays = [31,28,31,30,31,30,31,31,30,31,30,31] # -- loading json is simple -- # -- take link above for according json-file fileIN = open("c:/path/to/your/file/bitcoin_historical.json","r") pythonData = json.loads(fileIN.read()) fileIN.close() # -- now reading json data # -- then creating box # --> reading all values of a month and averaging them # --> creating only box per month positionX = 0 for year in range(2012,2018): for month in range(12): mo = str(month+1).zfill(2) avgVal = 0 for day in range(mDays[month]): dy = str(day+1).zfill(2) sKey = str(year)+"-"+mo+"-"+dy avgVal += pythonData['bpi'][sKey] #print sKey, "=>",pythonData['bpi'][sKey] avgVal = avgVal/mDays[month] obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Box) obj.ParameterBlock.Width.Value = 20 obj.ParameterBlock.Length.Value = 20 obj.ParameterBlock.Height.Value = avgVal node = MaxPlus.Factory.CreateNode(obj) node.Position = MaxPlus.Point3(positionX, 0, 0) node.Name = str(year)+"-"+mo positionX = positionX +40 |