Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read Json file

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
13831 Views, 4 Replies

Read Json file

Hey there,

 

I'm using 3ds Max 2017 and want to read a json file in my maxscript and be able to access items in the json.

 

Is this supported by max or will I have to download some third party library to achieve this?

 

Thanks.

4 REPLIES 4
Message 2 of 5
RGhost77
in reply to: Anonymous

Message 3 of 5
Swordslayer
in reply to: Anonymous

Since 2017 you can also use the python-maxscript interop, simply do  json = python.import #json   MAXScript side and you can call all its methods as if you were in python. Doesn't get much easier than that.

Message 4 of 5
Anonymous
in reply to: Anonymous

Hi, I need exactly the same thing - reading-writing json files from/to maxscript data (dictionary of strings, floats and arrays)

 

 

I could read/write using python only:

 

 

import json

fileIN = open ("D:\\TMP2\\original.json", "r")
pythonData = json.loads(fileIN.read())
fileIN.close()

fileOUT = open ("D:\\TMP2\\new.json", "w")
fileOUT.write(json.dumps(pythonData, indent=4))
fileOUT.close()

 

 

But this would result in a python dictionary; my question is how to have this as maxscript data.

 

I am trying to use

json = python.import #json 

 

but unfortunately I have no knowledge of python. 

It would be awesome if someone could help me get this working inside maxscript!

 

 

 

 

MANY THANKS!

 

 

 

 

 

 

PS this is the json file I am trying to read/write as maxscript dictionary / arrays

{
  "NumTextures": 2,
  "Positions": [
    [-0.19283, 0.00000, 26.94215],
    [0.19282, 0.00000, -26.94215]
  ],
  "Cameras": [
    [360, 180, [-0.19283, 0.00000, 26.94215], [-0.19283, 0.00000, 25.94215], [0.00000, 1.00000, 0.00000], "color0", "enabled"],
    [360, 180, [0.19282, 0.00000, -26.94215], [0.19282, 0.00000, -27.94215], [0.00000, 1.00000, 0.00000], "color1", "enabled"]
  ],
  "InitialPosition":  [-70.14005, 0.00000, 53.26647],
  "InitialRotation":  0,
  "NumNearCameras": 2,
  "NumWideCameras": 2,
  "BackColorFactorA": 20.0,
  "BackColorFactorB": 0.1,
  "BackRotation": 0
} 
Message 5 of 5
Anonymous
in reply to: Anonymous

Hi, I tried to convert my .obj file to json to load it with three.js. I've done that with MaxScript and the result is the following:

 

{

"metadata":
{
"sourceFile": "",
"generatedBy": "3ds max ThreeJSExporter",
"formatVersion": 3,
"vertices": 0,
"normals": 0,
"colors": 0,
"uvs": 0,
"triangles": 0,
"materials": 0
},

"materials": [
],

"vertices": [],

"normals": [],

"colors": [],

"uvs": [[]],

"faces": []

}

It returns empty [], what can I do?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report