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.

Evaluate FeatureScript request returns empty BTFSValueArray instead of face.

max_borshmax_borsh Member, Developers Posts: 14
Hi everybody!
I want to determine the geometryId for existing face (upper face of extrude).
I have featureId of extrude that I got from response (feature -> message -> featureId. "FjEqUFlhNuPViCq_0", for example)

I sent evaluating FeatureScript request like this:
"FjEqUFlhNuPViCq_0", false), EntityType.FACE))); }
function(context is Context, queries){ return transientQueriesToStrings(evaluateQuery(context, qEntityFilter(qCapEntity(newId() +
but in response I have only empty BTFSValueArray. What am I doing wrong?

 P.S.: documentID, workspaceID, elementID, serializationVersion, sourceMicroversion were added with evaluate FS request.

Thank you in advice!

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    I don't see anything immediately wrong, but what is going on is that your query is not resolving to anything.  Can you create a custom feature in that document that calls
    "FjEqUFlhNuPViCq_0", false), EntityType.FACE))debug(context,&nbsp;<code>qEntityFilter(qCapEntity(newId() + 
    and see if that works?
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • max_borshmax_borsh Member, Developers Posts: 14
    Thank you for answer, Ilya!

    Okay, I did it.
    I created a custom feature with this call after the extrude feature via API was created. And I see the face that I need through debug. I can even get the transientId by using transientQueriesToStrings and println:

    <div>debug(context, qEntityFilter(qCapEntity(newId() + "FBdS264Dn0b9qW0_0", false), EntityType.FACE));
    println(transientQueriesToStrings(evaluateQuery(context, qEntityFilter(qCapEntity(newId() + "FBdS264Dn0b9qW0_0", false), EntityType.FACE))));</div>
        And what I can see:

    But If I use same request via API (using C# HttpClient) it returns nothing (json that doesn't contain notices(errors) but contains  empty BTFSValueArray).
    Another requests I sent (determine geometry of front plane, create sketch etc) worked fine.

    Works fine:
    planeDetermination = await SendObjectAsJsonAsync<object>(
                    String.Format(OnshapeAPIConstants.FEATURES_FEATURE_SCRIPT, documentID, workspaceID, elementID),
                new OnshapeFeatureScriptEvaluationRequest()
                {
                    script = "function(context is Context, queries){ return transientQueriesToStrings(evaluateQuery(context, qCreatedBy(makeId(\"Front\"), EntityType.FACE)));}",
                    serializationVersion = serializationVersion,
                    sourceMicroversion = sourceMicroversion,
                    queries = new object[0]
                });
    
    Doesn't work:
    planeDetermination = await SendObjectAsJsonAsync<object>(
                    String.Format(OnshapeAPIConstants.FEATURES_FEATURE_SCRIPT, documentID, workspaceID, elementID),
                new OnshapeFeatureScriptEvaluationRequest()
                {
                    script = "function(context is Context, queries){{ return transientQueriesToStrings(evaluateQuery(context, qEntityFilter(qCapEntity(newId() + \"FBdS264Dn0b9qW0_0\", false), EntityType.FACE)));}}",
                    serializationVersion = serializationVersion,
                    sourceMicroversion = sourceMicroversion,
                    queries = new object[0]
                });
    
    Thank you in advise!
  • mark_noyesmark_noyes Member, Onshape Employees, Developers Posts: 21
    It looks like the issue is related to the use of the sourceMicroversion parameter. The API is using that as the scope for evaluating your request. If that microversion does not identify a point in the model history in which the identified feature exists, you will get an empty list back.  I suspect that you are passing a microversion for a model state prior to your extrude. The Front plane exists in the initial microversion for the Part Studio, so it does not have this issue.

    If you remove the sourceMicroversion field from your request, you will probably find this does what you expect.
  • max_borshmax_borsh Member, Developers Posts: 14
    Mark, thank you so much!

    It's exactly what I need!
Sign In or Register to comment.