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.
Using partQuery in FeatureScript to retrieve parts
morteza_karimi
Member Posts: 13 ✭
Hi,
I noticed the "get parts in PartStudio" returns a partQuery that looks like below:
"partQuery": "query=qCompressed(1.0,\"&1c6$eJx1UMFygjAU/Jn06ggFhCOQYFMrwSQzVi9MgFSj1iDEtv59g8z00vH43u6+3X1PiQ9WV9ndlj5zXNCoXnxWancVRukzFEbEztL9j/BbK5nzDAjFc5zHbyVEBcohytMNi4Du1E6dxamPvXRqDwsgz0aZ26BKBEB/A/MAgnPEKrBXvdHduAxBSlHMMcktoFvZ3S1xk7gAN7HDHGcSgOw1CCOOk9ihcGHacvqtOkla634Z6twPNYAtEE9fSpRzzDdMgv4oTb0fA+CG1RMfHAoS37irzXLNbe69GSJTj/o0oDMaUkErWlPLBeF6So6rBakyHT0kcRjk8HBsI0RXD0mzD/2eXerMbH9O1EsD+4eEwM3IS6uxYwQyBbe6/WpI4Rf0YjvqFv2Y7tpIWtmnsjUqeDkIfwEBEZNK\",id);"
I was wondering if this query can be used in a FeatureScript to find a specific part. I'm looking for a way to link the metadata I'm getting through the API back to parts inside a FeatureScript and from what I understand PartIDs can't be used because they are assigned after featureScripts is done regenerating. But can this partQuery or any other property be used to achieve this?
Thanks,
Tagged:
0
Comments
"type": 134,
"typeName": "BTMFeature",
"message": {
"featureType": "add_custom_attributes",
"name": "aca-1",
"namespace": "e5f4833f4feab2a1258969790::me4f227b60dcb6ada238eb126",
"parameters": [
}
}
Are these part studios constructed interactively in Onshape? Is someone going to want to modify those part studios after the attributes are attached? Because if so, you definitely don't want to refer to parts by part ids, as those will change if parts are edited.
One possibility is creating a custom feature with an array parameter, where each array item consists of a query for a part and an isAnything parameter for the attributes.
Another possibility (though less nice) is using the compressed query string in the JSON file, as I think you suggested -- you'd iterate over the data in the JSON file and attach the attributes to the query results.
Does this help?
"propertyType" : PropertyType.APPEARANCE,
"value" : color(definition.R / 255., definition.G / 255., definition.B / 255., 1)
});
Thanks,
I recommend the first approch. Here's a public document that shows how the feature can work: https://cad.onshape.com/documents/0f85058bb5f40b8535a4f8de/w/7daa1dc09bec441651d39f8d/e/0637ea3ac59e4d5f24be41b1
To answer your question, on the FS side, the query is just a query. For work with the API, Onshape exposes the query as a partId.
"featureSpecs" : [ {
"type" : 129,
"typeName" : "BTFeatureSpec",
"message" : {
"featureType" : "partColors",
"featureTypeName" : "Part Colors",
"manipulatorChangeFunction" : "",
"parameters" : [ {
"type" : 2600,
"typeName" : "BTParameterSpecArray",
"message" : {
"parameters" : [ {
"type" : 174,
"typeName" : "BTParameterSpecQuery",
"message" : {
"filter" : {
"type" : 124,
"typeName" : "BTEntityTypeFilter",
"message" : {
"entityType" : "BODY"
}
},
"maxNumberOfPicks" : -1,
"additionalBoxSelectFilter" : {
"type" : 0
},
"parameterId" : "query",
"parameterName" : "Part Query",
"uiHint" : "",
"defaultValue" : {
"type" : 148,
"typeName" : "BTMParameterQueryList",
"message" : {
"queries" : [ ],
"parameterId" : "query",
"hasUserCode" : false,
"nodeId" : "MnrEFMPwxpoD12Abk"
}
},
"visibilityCondition" : {
"type" : 0
},
"uiHints" : [ ],
"columnName" : ""
}
}, {
"type" : 173,
"typeName" : "BTParameterSpecQuantity",
"message" : {
"quantityType" : "ANYTHING",
"ranges" : [ ],
"parameterId" : "data",
"parameterName" : "Data, e.g. RGB",
"uiHint" : "",
"defaultValue" : {
"type" : 147,
"typeName" : "BTMParameterQuantity",
"message" : {
"units" : "",
"value" : 0.0,
"expression" : "0",
"isInteger" : false,
"parameterId" : "data",
"hasUserCode" : false,
"nodeId" : "MgoD4pCV/gl/wvy16"
}
},
"visibilityCondition" : {
"type" : 0
},
"uiHints" : [ ],
"columnName" : ""
}
} ],
"itemName" : "Part",
"itemLabelTemplate" : "",
"drivenQuery" : "query",
"parameterId" : "parts",
"parameterName" : "Parts",
"uiHint" : "",
"defaultValue" : {
"type" : 2025,
"typeName" : "BTMParameterArray",
"message" : {
"items" : [ ],
"parameterId" : "parts",
"hasUserCode" : false,
"nodeId" : "MEuldRVLx+pMrZSCO"
}
},
"visibilityCondition" : {
"type" : 0
},
"uiHints" : [ ],
"columnName" : ""
}
} ],
"uiHints" : [ ],
"namespace" : "e32c93d3896b65163a3ca1fbc::mc1c4abff1a359f9996f90365",
"filterSelectors" : [ ],
"featureNameTemplate" : "",
"editingLogic" : {
"type" : 0
},
"languageVersion" : 1024,
"sourceMicroversionId" : "c1c4abff1a359f9996f90365",
"sourceLocation" : {
"type" : 226,
"typeName" : "BTLocationInfo",
"message" : {
"document" : "32c93d3896b65163a3ca1fbc",
"version" : "c1c4abff1a359f9996f90365",
"topLevel" : "",
"parseNodeId" : "PI1qCJfM+Bhe8Acdy",
"character" : 160,
"line" : 5,
"column" : 27,
"endCharacter" : 966,
"endLine" : 28,
"endColumn" : 7,
"languageVersion" : 1024,
"moduleIds" : {
"type" : 1897,
"typeName" : "BTDocumentVersionElementIds",
"message" : {
"documentId" : "",
"versionId" : "",
"elementId" : "32c93d3896b65163a3ca1fbc"
}
},
"elementMicroversion" : "c1c4abff1a359f9996f90365",
"nodeId" : "DTiQTQHJeo1K+HZ6"
}
},
"linkedLocationName" : ""
}
} ],
"serializationVersion" : "1.1.16",
"sourceMicroversion" : "89a192cfd82bb8cafcfb693e",
"rejectMicroversionSkew" : false,
"microversionSkew" : false,
"libraryVersion" : 0
}