Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_lee103jiahao_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"
} ], ..

Comments

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 221

    If you want the queryString referenced in features, it maybe simpler to get the list of features & extract the queryStrings from the features. The transientQueriesToStrings method will return the deterministicIds.

  • jiahao_lee103jiahao_lee103 Member Posts: 14 EDU
    edited December 2024

    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:

      body = {
    "script":
    "function(context is Context, queries) { "
    " const _ = 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\", makeId(\"FkAc0mg4NYcOSCa_1\"));"


    # " canBeQuery(_);" # true
    " const q = evaluateQuery(context, _);"

    " return q;"
    "}"
    }
    res = self._api.request("post",
    "/api/v10/partstudios/d/" + self.did + "/w/" + self.wid + "/e/" + self.eid + "/featurescript",
    body=body)

    evaluateQuery(context, _) return an empty array:

    "result": {
    "btType": "com.belmonttech.serialize.fsvalue.BTFSValueArray",
    "value": [],
    "typeTag": ""
    },

    So my questions is:

    Question

    In feature list, the entities content is like:

    {
    "featureType": "chamfer",
    "btType": "BTMFeature-134",
    "name": "Chamfer 1",
    "featureId": "FkAc0mg4NYcOSCa_1",
    "parameters": [
    {
    "parameterId": "entities",
    "btType": "BTMParameterQueryList-148",
    "nodeId": "fuIh17TZu52EKemJ",
    "queries": [
    {
    "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"
    ],

    https://cad.onshape.com/documents/35472159f025cdc9f3dceadf/w/e697a0ab884317ecffe02f25/e/0be68b867fee1010f3e8d1f6

    The id in qCompressed is a variable. I set it to the corresponding featureId through makeId(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!

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 221

    Hi jiahao_lee103,

    1. The "deterministicIds" i.e. "deterministicIds": ["JHW"] in the response , is the result of evaluating the query in the queryString. You can directly use it, instead of re-evaluating the queryString.
    2. If you want to evaluate the queryString to get the id, you need to pass in 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()))); }"}

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 221

    » 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.

  • jiahao_lee103jiahao_lee103 Member Posts: 14 EDU

    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?

Sign In or Register to comment.