I need to save all the changes in the scene to MarkupView
Hello @15089700278,
The title of your post and your actual question appear to be two different topics so Iām not sure if you had meant to ask multiple questions.
With respect to saving a MarkupView object, we have an example of saving it in our docs. As a quick summary, below are the calls:
//Create a markup view
const uniqueId = hwv.markupManager.createMarkupView("Markup View");
//Activate the markup view
hwv.markupManager.activateMarkupViewWithPromise(uniqueId);
Thanks,
Tino
Hello @tino
I want to call the hwv.model.createCadView
method to create a view. How should I quickly get the position changes of nodes in the scene nodeIdsAndLocalTransforms
Thanks
Hello @15089700278,
For a given node id, you can retrieve its transformation matrix (if one has been set) via the function getNodeMatrix.
You can then recursively walk the tree and accumulate the node id and node matrix pair:
function walkNodes(nodeId) {
let result = [];
console.log("Walk Node " + nodeId);
var children = hwv.model.getNodeChildren(nodeId);
console.log("Found " + children.length + " child nodes");
for (var i = 0; i < children.length; i++) {
let nodeMatrix = hwv.model.getNodeMatrix(children[i]);
result.push([children[i], nodeMatrix]);
console.log("Node " + children[i]);
console.log(nodeMatrix);
result = result.concat(walkNodes(children[i]));
}
return result;
}
function walkAllNodes() {
var rootid = hwv.model.getAbsoluteRootNode();
let nodeMatrixPairs = walkNodes(rootid);
console.log(nodeMatrixPairs);
return nodeMatrixPairs;
}
Thanks,
Tino
1 Like