Project File Edit

Wrap project file is a simple text file in JSON format. It can be easily read and fixed in any text editor.

Project File Structure

Below is an example of a project file that contains two nodes Load and Subdivide. It first loads a geometry from an *.obj file and then subdivides it. The full project file can be downloaded here.

Project.wrap
{
    "formatVersion": 0,
    "nodes": {
        "Load": {...},
        "Subdivide": {...},
    },
    "timeline": {
        "current": 0,
        "max": 10,
        "min": 0
    }
}

In some cases it might be useful to be able to find and change a node parameter inside the project file from a text editor or a custom script.

For example, we want to change this project so that it would load a geometry from another *.obj file.

Let’s take a look at the node Load that loads a geometry.

"Load": {
    "isAlwaysVisible": true,
    "nodeId": 0,
    "nodeType": "LoadGeom",
    "params": {
        "fileNames": {...},
        "texture": {...},
        "transform": {...},
        "visualParam": {...}
        }
    },
    "x": 262,
    "y": 242
},

We can see that the node has 4 parameters one of which is fileNames.

"fileNames": {
    "connectedNodeId": -1,
    "dataType": "StringList",
    "value": [ "C:/Models/Alex.obj" ]
},

Changing a file name is straightforward. All we need is to do is to change the line

"value": [ "C:/Models/Alex.obj" ]

to the line

"value": [ "C:/Models/John.obj" ]

Edit Project File with Python

The previous operation can be done with few lines of Python script

import json
f = open('Project.wrap','r')
project = json.loads(f.read())
project['nodes']['Load']['params']['fileNames']['value'] = ['C:/Models/John.obj']
f.close()

To write the edited project back to file we can do

f = open('Project.wrap','w')
f.write(json.dumps(project))
f.close()

You can also use a Command Line Interface to compute the edited project in Wrap.

Warning

The project file format is not guaranteed to be consistent in future. You can use project edit as a temporal solution for automation until we include a Python scripting support to Wrap.