How to get transformation values?

I’ following Product Configurator tutorial in which JSON file is provided which contain transformation for individual parts of bicycle model. I’m building similar application in which I’ve scs model file so How can I get transformation for each part of scs model in JSON file.
For example microengine.scs is my model so how can i get transfomation info for each part in JSON file so I can build microengine from scratch by adding one part at a time.


there are basically two approaches to retrive all the matrices from a model.

  1. After loading the model in the viewer recursively go through all nodes in the model and retrieve the matrices. Below is some code that accomplishes that and returns the result as a stringified JSON object:
  function getAllMatrices(node,matrixarray,viewer)
        let children = viewer.model.getNodeChildren(node);
        let matrix = hwv.model.getNodeMatrix(node).toJson();
        matrixarray.push({node:node, matrix:matrix});
        for (let i=0;i<children.length;i++)

    function getMatricesAsJSON(viewer)
        let matrixarray = [];
        let json = JSON.stringify(matrixarray);
        return json;
  1. Generate an assembly tree xml for the model you are interested in during import via converter with the command line option –output_xml_assemblytree. You can then parse that file to retrieve the relevant matrices for every node. You can find more information on the content of that assembly tree file here.

Let me know if you have further questions.


1 Like

thanks for your reply
First approached that you’ve mentioned will try to implement.
Second approach I already tried and generated xml file by following Generating XML Model Structure File

What I’ve done is created shattered assembly which contain multiple SCS file and then i tried to load one part at time using this call

model.loadSubtreeFromScsXmlFile(rootNode,"microengine.xml",(name)=>{return microengine_shattered/${name};})

but what it does instead of loading one part at a time it loads whole model I did not understand what third parameter does exactly.



the third parameter in this function is a callback that allows you to modify the name/path of the scs files referenced in the XML so that they point to one of your local subdirectories or have a specific extension for example.

However, if all you want is load a single scs file you would use loadSubtreeFromScsFile and not this function. In case of querying the matrices the XML file would just be used server-side to query this information.

So just to be clear, the purpose of loadSubtreeFromScsXML file is to load a whole assembly that consists of “shattered” parts, meaning each part in the assembly has its own scs file. In your case what you want is to load a single part but with the appropriate matrix. Of course a part might be referenced multiple times in an assembly so there is no single matrix, you would really have to look at the nodeid for the part instance when parsing the XML.

I hope this helps.

okay this very well written and clearly address my question and clear my doubt.
And yes part might be referenced multiple times in an assembly it never occurred to me thanks for this. I will try this nodeId approach and will use loadSubtreeFromScsFile function.

1 Like