-
-
Save drcmda/5e5adfb3f2ee7c042e2ad1de338ba7bf to your computer and use it in GitHub Desktop.
toolbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 'url', default URL, depends on the analyzer running online or local | |
// 'Canvas', 'View', 'SocketIO' & 'Object3' from AWV3-next | |
// 'log' (.start(), .stop(message) & .printResults(string || object)) | |
log.start(); | |
let tasks = []; | |
let task = new SocketIO().connect(url).then(connection => { | |
// Clear scene | |
view.scene.destroy(); | |
// Execute tasks and disconnect | |
return connection.request([ | |
{ | |
"task": "_C.ToolDesigner3d.InitApplication(\"3DToolDesigner.of1\");", | |
"command": "Execute" | |
}, | |
{ | |
"task": "_O.ToolDesigner3d.CreateTool(\"Test_Tool\",\"Drill\");", | |
"command": "Execute" | |
}, | |
{ | |
"task": "_O.ToolDesigner3d.AddComponent(\"adapter\",\"Drawings\\ISO_Comp\\HSKA63.of1\");", | |
"command": "Execute" | |
}, | |
{ | |
"task": "_O.ToolDesigner3d.AddComponent(\"extension\",\"Drawings\\ISO_Comp\\EXTc.of1\",[[\"Lmax\",\"Dstart\"],[10,2]]);", | |
"command": "Execute" | |
}, | |
{ | |
"task": "_O.ToolDesigner3d.AddComponent(\"nocut\",\"Drawings\\ISO_Comp\\EXTc.of1\",[[\"Lmax\",\"Dstart\"],[1,0.24]]);", | |
"command": "Execute" | |
}, | |
{ | |
"task": "_O.ToolDesigner3d.AddComponent(\"cut1\",\"Drawings\\ISO_Comp\\drlcutca.of1\",[[\"SIG\"],[118]]);", | |
"command": "Execute" | |
} | |
]) | |
.then( context => addModels(context, "1st task")) | |
.then( () => connection.execute(`RETURN CADH_JSONTreeExportStr(_O.Demo_Tool);`)) | |
.then( context => addModels(context, "2nd task")) | |
.then( () => connection.disconnect()); | |
}); | |
tasks.push(task); | |
Promise.all(tasks).then( () => log.stop("Tasks completed!")); | |
function addModels(context, descr = "") { | |
log.printResults(descr); | |
log.printResults(context.results); | |
let object = new Object3(context.models); | |
view.scene.add(object); | |
view.updateBounds().controls.zoom().focus(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment