Question about how to see which two parts mateConnector connects by using the OnShape API
C_Justin
Member Posts: 16 ✭
I'm curious about how to see which two parts mate connector connects by using the API provided by OnShape. So when I get the features list from API, I cannot find a property in that json file that can represent the two parts that the mate connector connects.
Tagged:
0
Best Answer
-
Hi @C_Justin,
I am assuming that you are using the Assembly getAssemblyDefinition API and that you have passed includeMateFeatures as true.
If that is the case the rootAssembly object in the response should have a features array.
In the featureData object of each object in the features array there should be a 2-object matedEntities array. Each object in the matedEntities array has a matedOccurrence field which is an array of strings.
This set of strings will correspond to the path of one of the objects in the occurrences array. If there is only one value in this array, that value will correspond directly to the id field of one of the objects in the instances list. If there is more than one string in the array (i.e. the mated occurrence is in a subassembly), you can follow the ids into the subAssemblies array to find the correct instance.{ "rootAssembly": { "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "e1368b732a843887c3d2cf9a", "occurrences": [ { "path": [ "MjRH9Zqu7dOIU67CJ" ], "transform": [ 1, 0, 0, 0.07574482075870037, 0, -1, 0, -0.016, 0, 0, -1, 0.024, 0, 0, 0, 1 ], "fixed": false, "hidden": false }, { "path": [ "M+M6+VzF+2sldfmTc" ], "transform": [ 1, 0, 0, 0.075, 0, 1, 0, -0.019, 0, 0, 1, -0.027, 0, 0, 0, 1 ], "fixed": false, "hidden": false } ], "instances": [ { "id": "MjRH9Zqu7dOIU67CJ", "name": "Part 1 <1>", "partId": "JHD", "isStandardContent": false, "configuration": "default", "type": "Part", "suppressed": false, "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6" }, { "id": "M+M6+VzF+2sldfmTc", "name": "Part 1 <2>", "partId": "JHD", "isStandardContent": false, "configuration": "default", "type": "Part", "suppressed": false, "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6" } ], "features": [ { "featureType": "mate", "id": "MveWxwoavJiCrcqye", "suppressed": false, "featureData": { "name": "Revolute 1", "mateType": "REVOLUTE", "matedEntities": [ { "matedOccurrence": [ "MjRH9Zqu7dOIU67CJ" ], "matedCS": { <information about the coordinate system> } }, { "matedOccurrence": [ "M+M6+VzF+2sldfmTc" ], "matedCS": { <information about the coordinate system> } } ] } } ] }, "subAssemblies": [], "parts": [ { "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6", "partId": "JHD", "bodyType": "solid", "configuration": "default", "isStandardContent": false } ], "partStudioFeatures": [] }
That is output from an extremely simple assembly (two instances and a single mate). Note that the strings in the two matedOccurrence arrays directly correspond to ids in the instances array.
1
Answers
-
Hi @C_Justin,
I am assuming that you are using the Assembly getAssemblyDefinition API and that you have passed includeMateFeatures as true.
If that is the case the rootAssembly object in the response should have a features array.
In the featureData object of each object in the features array there should be a 2-object matedEntities array. Each object in the matedEntities array has a matedOccurrence field which is an array of strings.
This set of strings will correspond to the path of one of the objects in the occurrences array. If there is only one value in this array, that value will correspond directly to the id field of one of the objects in the instances list. If there is more than one string in the array (i.e. the mated occurrence is in a subassembly), you can follow the ids into the subAssemblies array to find the correct instance.{ "rootAssembly": { "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "e1368b732a843887c3d2cf9a", "occurrences": [ { "path": [ "MjRH9Zqu7dOIU67CJ" ], "transform": [ 1, 0, 0, 0.07574482075870037, 0, -1, 0, -0.016, 0, 0, -1, 0.024, 0, 0, 0, 1 ], "fixed": false, "hidden": false }, { "path": [ "M+M6+VzF+2sldfmTc" ], "transform": [ 1, 0, 0, 0.075, 0, 1, 0, -0.019, 0, 0, 1, -0.027, 0, 0, 0, 1 ], "fixed": false, "hidden": false } ], "instances": [ { "id": "MjRH9Zqu7dOIU67CJ", "name": "Part 1 <1>", "partId": "JHD", "isStandardContent": false, "configuration": "default", "type": "Part", "suppressed": false, "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6" }, { "id": "M+M6+VzF+2sldfmTc", "name": "Part 1 <2>", "partId": "JHD", "isStandardContent": false, "configuration": "default", "type": "Part", "suppressed": false, "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6" } ], "features": [ { "featureType": "mate", "id": "MveWxwoavJiCrcqye", "suppressed": false, "featureData": { "name": "Revolute 1", "mateType": "REVOLUTE", "matedEntities": [ { "matedOccurrence": [ "MjRH9Zqu7dOIU67CJ" ], "matedCS": { <information about the coordinate system> } }, { "matedOccurrence": [ "M+M6+VzF+2sldfmTc" ], "matedCS": { <information about the coordinate system> } } ] } } ] }, "subAssemblies": [], "parts": [ { "documentId": "1c24b14e01117ef330f0a394", "documentMicroversion": "f67044055c21aabcff2d8114", "elementId": "636c00f09ae5637b88b798e6", "partId": "JHD", "bodyType": "solid", "configuration": "default", "isStandardContent": false } ], "partStudioFeatures": [] }
That is output from an extremely simple assembly (two instances and a single mate). Note that the strings in the two matedOccurrence arrays directly correspond to ids in the instances array.
1 -
Thank you so much!0

