Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Is there a way to get specific information of a mate from API?
C_Justin
Member Posts: 16 ✭
Is there a way to get how a mate limit two different parts from API? Like which axis the mate will constraint and how much freedom are allowed on each direction?
Tagged:
0
Best Answer
-
Ethan_K Member, Onshape Employees Posts: 57There is. You will have to call the assembly feature list API. For example, I made an assembly with a revolute mate limited to 45 degree rotation here: https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/369ac699891d9659ce2d42ba/e/32fbe5d87f9b2777a37ddee9 . When you call this endpoint (just put it into your browser that is signed in to Onshape): https://cad.onshape.com/api/assemblies/d/cca81d10f239db0db9481e6f/v/369ac699891d9659ce2d42ba/e/32fbe5d87f9b2777a37ddee9/features you should get the following: (I deleted the nonessential bits for brevity)
{"features": [
{
Under features[0]["message"]["parameters"][2]["message"]["expression"], you'll see my z axis offset of "-0.25 in", and under features[0]["message"]["parameters"][5]["message"]["expression"], you'll see my z axis axial limit of "45 deg". Note that these parameter lists don't have a guaranteed order, so don't hardcode the location (here, 2 or 5). Instead, you should filter based on the type, and subsequently the parameterId. For the offset, the type is "BTMParameterQuantity" and the parameterId is "mateOffsetDistanceZ". For the limit, type is "BTMParameterNullableQuantity" with a parameterId of "limitAxialZMax". Hope that makes sense!
"type": 64,
"typeName": "BTMMate",
"message": {
"mateConnectors": [],
"version": 2,
"featureType": "mate",
"featureId": "MHRrbsJgjRWu3+Iaf",
"name": "Revolute 1",
"parameters": [
{
"type": 145,
"typeName": "BTMParameterEnum",
"message": {
"enumName": "Mate type",
"value": "REVOLUTE",
"namespace": "",
"parameterId": "mateType",
"hasUserCode": false,
"nodeId": "pfmse+zfxKRK6dpx"
}
},
{
"type": 144,
"typeName": "BTMParameterBoolean",
"message": {
"value": true,
"parameterId": "mateOffsetEnabled",
"hasUserCode": false,
"nodeId": "hlflbMRsVZ/Es5eF"
}
},
{
"type": 147,
"typeName": "BTMParameterQuantity",
"message": {
"units": "",
"value": 0.0,
"expression": "-0.25 in",
"isInteger": false,
"parameterId": "mateOffsetDistanceZ",
"hasUserCode": false,
"nodeId": "J+LuPhxB+1t4vnYa"
}
},
{
"type": 144,
"typeName": "BTMParameterBoolean",
"message": {
"value": true,
"parameterId": "limitsEnabled",
"hasUserCode": false,
"nodeId": "ZKIZpuNWOeRbZ0dM"
}
},
{
"type": 807,
"typeName": "BTMParameterNullableQuantity",
"message": {
"isNull": false,
"nullValue": "",
"units": "",
"value": 0.0,
"expression": "0 deg",
"isInteger": false,
"parameterId": "limitAxialZMin",
"hasUserCode": false,
"nodeId": "KVXmU7kM3+EMaFjq"
}
},
{
"type": 807,
"typeName": "BTMParameterNullableQuantity",
"message": {
"isNull": false,
"nullValue": "",
"units": "",
"value": 0.0,
"expression": "45 deg",
"isInteger": false,
"parameterId": "limitAxialZMax",
"hasUserCode": false,
"nodeId": "OxNBRDEYP++UdZT8"
}
},
{
"type": 144,
"typeName": "BTMParameterBoolean",
"message": {
"value": true,
"parameterId": "primaryAxisAlignment",
"hasUserCode": false,
"nodeId": "Af/1L8J6jK45NqU/"
}
},
{
"type": 145,
"typeName": "BTMParameterEnum",
"message": {
"enumName": "Reorient secondary axis",
"value": "PLUS_X",
"namespace": "",
"parameterId": "secondaryAxisAlignment",
"hasUserCode": false,
"nodeId": "It64Nf/o+SfvHv/S"
}
}
],
"suppressed": false,
"namespace": "",
"subFeatures": [],
"returnAfterSubfeatures": false,
"suppressionState": {
"type": 0
},
"hasUserCode": false,
"nodeId": "MHRrbsJgjRWu3+Iaf"
}
}
],
"featureStates": [
{
"key": "MHRrbsJgjRWu3+Iaf",
"value": {
"type": 1688,
"typeName": "BTFeatureState",
"message": {
"featureStatus": "OK"
}
}
}
],
"isComplete": true,
"serializationVersion": "1.1.16",
"sourceMicroversion": "e6688ceaaf1f929e8d0bcd47",
"rejectMicroversionSkew": false,
"microversionSkew": false,
"libraryVersion": 0
}
6
Answers
Under features[0]["message"]["parameters"][2]["message"]["expression"], you'll see my z axis offset of "-0.25 in", and under features[0]["message"]["parameters"][5]["message"]["expression"], you'll see my z axis axial limit of "45 deg". Note that these parameter lists don't have a guaranteed order, so don't hardcode the location (here, 2 or 5). Instead, you should filter based on the type, and subsequently the parameterId. For the offset, the type is "BTMParameterQuantity" and the parameterId is "mateOffsetDistanceZ". For the limit, type is "BTMParameterNullableQuantity" with a parameterId of "limitAxialZMax". Hope that makes sense!