Project
Loading project
In order to force netDecor to open project send by webpage, call window.NetDecor.Project.Open:
window.NetDecor.Project.Open(buffer: Uint8Array, params: string);
buffer : Uint8Array – typed array with project data
params : String – JSON string with additional project data, e.g. ID or project’s name.
id : string – Project ID. If this exist, netDecor will send it while saving project.
name : string – Project name. If this exists, netDecor will send it while saving project and will show it in top-level bar in app UI, where it is modifiable by user.
readOnly : boolean – flag that marks project as read only. Program will block all tabs besides 'File’, 'Help’ and 'Basket’. Additionally, entering changes into scene is also blocked. Save action is not blocked.
Example
function whenReady(){
var req = new XMLHttpRequest();
req.open("GET","http://localhost:8001/project2.npf", true);
req.responseType = "arraybuffer";
req.onload = function (oEvent) {
var blob = new Uint8Array(req.response);
NetDecor.Project.Open(blob,
JSON.stringify({id: "546536"}));
};
req.send();
}
RunNetPlusApp("appcontainer", "Build/", "{\"dbaddr\":\"http://dev.netdecor.cadprojekt.com.pl/Example-Database/\"}",whenReady);
Project is loaded after full app initialization and after basic database data is downloaded. Projects are not queued, only overwritten. That is why after app startup last send project will be loaded.
If both buffer and params are null new project window will be shown instead. Example:
RunNetPlusApp("appconatiner", "Build/", runParams, function(){
NetDecor.Project.Open(null, null)
});
Method will throw exceptions in case of bad project buffer or when not valid param will be sent.
Save project
To register event handler on save action, you need to call:
window.NetDecor.Events.RegisterEventHandler("SaveProject", function(buffer: Uint8Array, pngBuffer: Uint8Array, params: string));
buffer : Uint8Array – byte array with project data
pngBuffer : Uint8Array – byte array with preview (PNG)
params : string – JSON project parameters, e.g ID
Parameters available in params:
id : string – Project ID. Will be send only if it was created.
name : string – Project name.
Example
function onReady(){
NetDecor.Events.RegisterEventHandler("SaveProject",function(buffer, png, jsondata, items) {
console.log("project size: "+ buffer.length);
console.log("png size: " + png.length);
console.log("json params: " + jsondata);
console.log("items: " + items);
});
}
RunNetPlusApp("appconatiner", "Build/", runParams, onReady);