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.

The TransientId for a newly created plane. (Onshape API)

max_borshmax_borsh Member, Developers Posts: 14
Hi Everybody.
I want to create an extrude feature by using Onshape Api. 
So, there is a great example at Depeloper portal (Feature list API -> Example 3).
But there is a way that describes how to create sketch on  the pre-defined front plane. What about creating the custom one? 

As far as I understand, I have to get the transientId by evaluating FeatureScript request and then use it while creating new sketch feature by passing this Id as parameter:
{
  "feature" : {
    "type": 151,
    "typeName": "BTMSketch",
    "message": {
      "entities": [...],
      "constraints": [...],   
      "parameters": [
        {
          "type": 148,
          "typeName": "BTMParameterQueryList",
          "message": {
            "queries": [
              {
                "type": 138,
                "typeName": "BTMIndividualQuery",
                "message": {
                  "geometryIds": [
                    "JCC" // here it is 
                  ]...
}
So I tried to create a new plane through invoking evaluate FeatureScript request (sending a script) like this:
script = "function(context is Context, queries is map){ // I couldn't get Id as parameter.
opPlane(context, id + "plane1", {
              "plane" : plane(vector(0, 0, 0) * inch, vector(0, 0, 1)),
              "width" : 10 * inch,
              "height" : 10 * inch
});
return transientQueriesToStrings(evaluateQuery(context, qCreatedBy(id + "plane1", EntityType.FACE)));
}",
But I couldn't get Id for this function. Is the way how can I get transientId for a newly created custom pane?
Same question about Determining Origin GeometryId for custom vector..

Thank you in advice!

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,217
    You cannot add new features (including planes) using the evaluate FeatureScript API call.  To figure out the transient id for a plane already in your feature list, you can use your script without the opPlane call and with newId() + "planeFeatureIdFromTheFeatureList" instead of id + "plane1" inside qCreatedBy, with the feature id substituted appropriately.

    Hope this helps.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • max_borshmax_borsh Member, Developers Posts: 14
    Thank you for answer, Ilya!

    And last question:
    To figure out the transient id for a plane already in your feature list...
    What is the best practice to get the needed face of already created extrude feature(created via onshape api) and than create a new plane on this face? 

    For example, can I do something like thing described below? 
    -create extrude (like "Example 3" in "feature list" section)
    -get upper face of this extrude;
    -create sketch and extrude it.

    Is there a way to get exactly upper face of all extrude features I created and to add new plane on it?

    Maybe, I can use featureId or some info that onshape returns in response to the extrude feature creating?
    Or have I to get an array of faces of the feature and to use specific one? (But how can I determine whith one I need?)

    Thank you in advice!
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    Hi Max,

    If I understand your question correctly I think you are looking for qCapEntity(<featrueId>, false).  This will give you all the faces at the end of an extrude feature.  You can use true instead of false for the starting faces instead of the ending faces.

    Good luck!
    Jake Rosenfeld - Modeling Team
  • lanalana Onshape Employees Posts: 711
    Slight correction: qCapEntity(<featrueId>, false) will give you all top faces edges and vertices, use 

    qEntityFilter(qCapEntity(<featrueId>, false), EntityType.FACE) to get faces only

  • max_borshmax_borsh Member, Developers Posts: 14
    Thank to everyone for help!

    But I hadn't done it yet..

    Let me describe my algorithm:
    - I've created extrude feature (going throw "Example 3") via onshape api.
    - I got featureId from response (feature -> message -> featureId). As far as I understand this Id I have to use for  qCapEntity. (let it be "FjEqUFlhNuPViCq_0")
    - I sent 
    evaluating FeatureScript request like this:
    function(context is Context, queries){{ return transientQueriesToStrings(evaluateQuery(context, qEntityFilter(qCapEntity(newId() + "FjEqUFlhNuPViCq_0", false), EntityType.FACE))); }
    or like this:
    function(context is Context, queries){{ return transientQueriesToStrings(evaluateQuery(context, 
    qEntityFilter(qCapEntity(evaluateQuery(context, qCreatedBy(newId() + "FjEqUFlhNuPViCq_0"))[0], false), EntityType.FACE)));}}
    but have "BTFSValueUndefined" or "array index 0 out of bounds" in response respectively. What am I doing wrong?

    By the way, I tried the same functions in FeatureScript editor and they are working great! But I have one more question:
    As far as I know, I have to determine the geometryId for the plane and the origin for new api request (for new sketch creating).
    I can get upper face and its vertices:

    But is there any way to get the center of this plane? (or to create the point with coordinates and get its transientId)

  • max_borshmax_borsh Member, Developers Posts: 14
    You cannot add new features (including planes) using the evaluate FeatureScript API call.  To figure out the transient id for a plane already in your feature list, you can use your script without the opPlane call and with newId() + "planeFeatureIdFromTheFeatureList" instead of id + "plane1" inside qCreatedBy, with the feature id substituted appropriately.

    Hope this helps.
    Thank you and your team for answers. But for me newId() works great with pre-defined planes. I got response with transientId and could use that. But It returns nothing if I try to do the same with existing face of extrude: { "console": "", "notices": [], "result": { "type": 1499, "typeName": "BTFSValueArray", "message": { "value": [], "typeTag": "" } }, "serializationVersion": "1.1.10", "sourceMicroversion": "03b2c38e6fe708899137ce87", "rejectMicroversionSkew": false, "microversionSkew": false, "libraryVersion": 483 }
Sign In or Register to comment.