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.
Please help me: `deterministicIds` DO NOT in ALL ids returned by `qeverything()`
jiahao_lee103
Member Posts: 14 EDU
I want to convert deterministicIds
(in feature list) into query and then parse it. The conversion code is as follows:
body = {
"script":
"function(context is Context, queries) { "
" const _ = qEverything();"
" const all_q = evaluateQuery(context, _);"
" var target_q = -1;"
" return transientQueriesToStrings(all_q);"
" for (var i = 0; i < size(all_q); i += 1) {"
" if (\"%s\" == all_q[i].transientId) {" % tid +
" target_q = all_q[i];"
" }"
" }"
#parse ...
"}",
}
res = self._api.request("post", "/api/v10/partstudios/d/" + did + "/w/" + wid + "/e/" + eid + "/featurescript",
body=body)
res_ = res.json()["result"]["value"]
But I found that the deterministicIds
in chamfer or fillet cannot be found in this way, so I can't resolve the edges or faces referenced by chamfer or fillet operations. Why does this happen? How should I solve this problem?
Below is a snippet from the feature list, which contains the entity IDs referenced by chamfer and fillet.
.. "name" : "Fillet 1",
"suppressed" : false,
"parameters" : [ {
"btType" : "BTMParameterEnum-145",
"namespace" : "",
"nodeId" : "s0mNttKDQSsG0DyB",
"enumName" : "FilletType",
"value" : "EDGE",
"parameterId" : "filletType"
}, {
"btType" : "BTMParameterQueryList-148",
"queries" : [ {
"btType" : "BTMIndividualQuery-138",
"queryStatement" : null,
"queryString" : "query=qCompressed(1.0,\"%B5$QueryM5S12$disambiguationDataA1M2S12$disambiguationTypeS13$ORIGINAL_DEPENDENCYS9$originalsA1C0M5Sa$entityTypeBa$EntityTypeS4$EDGESb$historyTypeS8$CREATIONSb$operationIdB2$IdA1S11.6$FGOtGUnjjNTgkPK_0wireOpS9$queryTypeSd$SKETCH_ENTITYSe$sketchEntityIdSc$KfxfNm3nASbMR4C6S4$FACER6R7R8CbA1S11.9$FNJb7sDs7ut4Qgu_0opExtrudeRbSa$SWEPT_FACE\",id);",
"deterministicIds" : [ "JIq" ],
"nodeId" : "FYOJEjM52q5B5zT"
} ], .. "name" : "Chamfer 1",
"suppressed" : false,
"parameters" : [ {
"btType" : "BTMParameterQueryList-148",
"queries" : [ {
"btType" : "BTMIndividualQuery-138",
"queryStatement" : null,
"queryString" : "query=qCompressed(1.0,\"%B5$QueryM5S12$disambiguationDataA1M2S12$disambiguationTypeS13$ORIGINAL_DEPENDENCYS9$originalsA1C0M5Sa$entityTypeBa$EntityTypeS4$EDGESb$historyTypeS8$CREATIONSb$operationIdB2$IdA1S11.6$FGOtGUnjjNTgkPK_0wireOpS9$queryTypeSd$SKETCH_ENTITYSe$sketchEntityIdSc$KfxfNm3nASbMR4C6S4$FACER6R7R8CbA1S11.9$FNJb7sDs7ut4Qgu_0opExtrudeRbSa$SWEPT_FACE\",id);",
"deterministicIds" : [ "JHW" ],
"nodeId" : "Fa7FuglbD6nZMi2"
}, {
"btType" : "BTMIndividualQuery-138",
"queryStatement" : null,
"queryString" : "query=qCompressed(1.0,\"%B5$QueryM5S12$disambiguationDataA1M2S12$disambiguationTypeS13$ORIGINAL_DEPENDENCYS9$originalsA2C0M5Sa$entityTypeBa$EntityTypeS4$EDGESb$historyTypeS8$CREATIONSb$operationIdB2$IdA1S11.6$FGOtGUnjjNTgkPK_0wireOpS9$queryTypeSd$SKETCH_ENTITYSe$sketchEntityIdSc$9delQkV37VSqC0M5R4R5R6R7R8RaRbRcRdSc$JMwbFu0nRJJBR4R5R6R7R8CbA1S11.9$FNJb7sDs7ut4Qgu_0opExtrudeRbSa$SWEPT_EDGE\",id);",
"deterministicIds" : [ "JHF" ],
"nodeId" : "Fzp1jM2lf3yf1Uj"
} ], ..
0
Comments
If you want the
queryString
referenced in features, it maybe simpler to get the list of features & extract the queryStrings from the features. ThetransientQueriesToStrings
method will return the deterministicIds.Dear @Paul_J_Premakumar ,
Thank you for your prompt response and for sharing your insights on the approach.
I tried the method you mentioned but failed. My code is as follows:
evaluateQuery(context, _)
return an empty array:So my questions is:
Question
In feature list, the entities content is like:
The
id
inqCompressed
is a variable. I set it to the correspondingfeatureId
throughmakeId
(taking the above code snippet as an example, I set it to the featureId of Chamfer 1). Is this correct?I look forward to hearing your thoughts on this and thank you for your time and assistance!
Hi jiahao_lee103,
newId()
in the call to qCompressed for example, with this document : https://cad.onshape.com/documents/fa6695405b76e3f6952469e8/w/e0a3a95fbf60f2254d393c77/e/2abc17b0c7e832bb5fbd57ea, this code works{ "script": "function(context is Context, queries) { return transientQueriesToStrings(evaluateQuery(context,qCompressed(1.0, \"%B5$QueryM6S12$disambiguationDataA1M2S12$disambiguationTypeS13$ORIGINAL_DEPENDENCYS9$originalsA1C0M5Sa$entityTypeBa$EntityTypeS4$EDGESb$historyTypeS8$CREATIONSb$operationIdB2$IdA1S11.6.6$F8yaanKhR4f29nQ_0sketchwireOpS9$queryTypeSd$SKETCH_ENTITYSe$sketchEntityIdS9.3$rectangletopR4R5R6R7S7$isStartFR8CbA1S-c.7.9$extrudeopExtrudeRbS8$CAP_EDGE\", newId()))); }"}
» But I found that the
deterministicIds
in chamfer or fillet cannot be found in this way, so I can't resolve the edges or faces referenced by chamfer or fillet operations. Why does this happen? How should I solve this problem?The reason for this is once the chamfer or fillet feature executes, the edges they reference are no longer present after the regeneration. Hence they are not returned by qEverything. The way to solve this would be to get the query, move the rollback ( https://cad.onshape.com/glassworks/explorer#/PartStudio/updateRollback) just above the feature & then evaluate the query at this state.
Thank you very much! @Paul_J_Premakumar Your answer has completely cleared up my confusion!
But I have one last question, can the same effect be achieved by updating feature with
suppress=true
?