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.

Using fstable

alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭

This message was originally sent to api-support@onshape.com but I have not gotten a response.  The document below may not be accessible to everyone, but you can substitute any of your own documents.  This is regarding the tables tab on the right side of an Onshape part studio.


I’m trying to use  fstable.  It’s in Glassworks, but I don’t find a clear enough explanation of the parameters.  An attempt at using it gives me 500.  Can I get a full explanation of how to use this?

 

I’m trying to access the table Part Bounds Table, which appears to be automatically included in all documents.

https://cad.onshape.com/documents/c50f2682dc6ad2a4912320b5/w/0d10e0f1e25770b4911915fc/e/23b8b6013a85fc52603dcc19

 

Access the table in the part studio /d/w/e listed below.  I assume this would get the entire table, unless I’m required to specify which row (which part)?

 

Request URL

https://cad.onshape.com/api/partstudios/d/c7760e5af2f484fb6e4ca9fd/w/31811c7eff4cfd04ceb9b35e/e/3a634712da2efd8ea6dd2804/fstable?tableType=partBounds

Server response

Code

Details

500

Error: Internal Server Error

Response body

Download

{

  "code": 0,

  "supportCode": "0ca5de53156bb074117e8538",

  "moreInfoUrl": "",

  "message": "An internal error has occurred; support code 0ca5de53156bb074117e8538",

  "status": 500

}

Response headers

connection: keep-alive  content-length: 189  content-type: application/json;charset=utf-8  date: Fri,01 Jul 2022 20:10:07 GMT  on-request-id: 96eb6a70d877ac792ac1ce77  on-version: 1.149.5360.a0727191bac5  server-timing: traceparent;desc="00-0000000000000000322b7fcfb8bcfdc3-322b7fcfb8bcfdc3-01",traceparent;desc="00-0000000000000000322b7fcfb8bcfdc3-0000000000000000-01"  strict-transport-security: max-age=31536000; includeSubDomains  x-api-version: v2  x-content-type-options: nosniff  x-xss-protection: 1; mode=block

 


Creating knowledge-driven design automation software, for molds, etc.
www.virtualmold.com

Comments

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 214
    edited July 2022
    Hi @alan_baljeu,

    We are in the process of updating the glassworks documentation. In the meantime, hopefully this will help

    Step 1 : Open the custom table you want to query using the “Open Linked Document option”

    In this case PartBounds is at : https://cad.onshape.com/documents/c50f2682dc6ad2a4912320b5/v/86f60a812c0f90a5c4e91174/e/23b8b6013a85fc52603dcc19

    Get the featureType from the Custom table using the featureSpecs API

    Here the d/v/e corresponds to the linked custom tables document 

    https://cad.onshape.com/api/featurestudios/d/c50f2682dc6ad2a4912320b5/v/86f60a812c0f90a5c4e91174/e/23b8b6013a85fc52603dcc19/featurespecs

    From the response, the featureType is “partBounds” , this is also the name of the variable that stores the return value of defineTable

    Step 2: The arguments to the FSTable API are 

    did , wvm, wmid, eid : Correspond to the document that includes the custom table

    configuration : Configuration parameters ( if any) 

    tableNameSpace: This is the namespace of the Custom table feature script document The namespace of the table definition, empty or omitted if it's a standard table. For custom tables it'll usually be in the form d[docId]::v[versionId]::e[elementId]::m[microversionId]

    tableType : The name of the function that computes the table, this is also the FeatureType from the Featurespecs API

    tableParameters : The parameters to the table function. They are provided in a similar, but not exactly the same way as configuration parameters.  The overall syntax is:

    •      param1=value1;param2=value2;...;paramN=valueN
    •      For booleans, value must be `true` or `false`.
    •      For strings, value must be the string in double quotes.
    •      For enums, the value must be of the form EnumName.ENUM_VALUE.
    •      Anything else is considered a quantity.

    partId: If provided, the function will only return tables associated with that partId

    linkedDocumentId: The document Id of the Custom table feature script document, if it is linked

    The namespace for the partBounds custom table at this time is 

    dc50f2682dc6ad2a4912320b5::v86f60a812c0f90a5c4e91174::e23b8b6013a85fc52603dcc19

    PartBounds takes an enum parameter; so that would be ordering=BoundsOrdering.BY_LENGTH

    API Call:

    Putting the above together, and using this document as an example :

    https://cad.onshape.com/documents/9f01605eb60f435aa60196d9/w/0d86557e22f6b6197f21eb64/e/3a814e7f61e109aee42c51be?renderMode=0&rightPanel=customTablePanel&uiState=62c6fc3ecd5fca2f4674671d

    the API would be

    https://cad.onshape.com/api/partstudios/d/9f01605eb60f435aa60196d9/w/0d86557e22f6b6197f21eb64/e/3a814e7f61e109aee42c51be/fstable?tableNamespace=dc50f2682dc6ad2a4912320b5::v86f60a812c0f90a5c4e91174::e23b8b6013a85fc52603dcc19::mbc6821f050f09ea5d56ac3b8&tableType=partBounds&tableParameters=ordering=BoundsOrdering.BY_LENGTH


  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    I guess I should buy a lottery ticket today:


    @alan_baljeuI can see why you're asking this question. An API manual would be nice.
    @Paul_J_Premakumar the new api explorer is really nice.

    In your example above, the namespace for the partBounds custom table at this time should be:
    dc50f2682dc6ad2a4912320b5::v86f60a812c0f90a5c4e91174::e23b8b6013a85fc52603dcc19::mbc6821f050f09ea5d56ac3b8

    Your API call is correct.


  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    Thank you for the explanation.  I’m baffled why you made it so complex.  It’s a literal grid of values in the document, I would think it would be as easy as /d/w/e/tableID and I can work out the schema from the JSON.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    edited July 2022
    A lot of the api is like this, when you want something you'll need to build 5 queries to get your answer. Lately I've been passing this compute down to the client and letting your computer crunch the data vs. my server. I don't want my server doing this work. A server should just be a traffic cop sending an object to a client. The client in turns asks the server to get more data from OS. 

    Using localhost, you don't have a server. Your local computer will be crunching the objects for the next query. If the API supplies everything from onshape, it's going to be complicated. You want this version of a partstudio when using this version of a feature script, it's all there and is accessible through the API. I think we want this.

    I couldn't figure fstable out either. The good news is there appears to be some support for the API now. @Paul_J_Premakumar thanks for the explanation. To me, the nomenclature is difficult like what does "partsBound" mean? There's many things in the API that aren't user facing and we programmers have no idea what these things mean. Holy crap! there's never been a manual for the API in the past.

    A great manual would have an example for each function call like the one created above. Please create a link in glassworks for each function call in the api like the one above. Please don't make us fight the forum searching for answers.

    The example above is amazing, I just don't want to have to search the forum for the answers.


  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    edited July 2022
    @alan_baljeu I'm running nodejs on my server so I'm always in javascript and I like the fact that I'm in one language. 

    In C#, how good is the json parser? In my client & server code I always parse to an object, I never deal with json and it's easy to build these nested queries after parsing.

    most my code looks like this:
    o=jsonParse(jsonFromOS)
    o.tableType="partBounds" // I have accessor methods to the object
    o.rows.forEach(element => console.log(element)) // I can loop easily within the object, I don't have to set up an array.
    sendJson(o) // I always send back what I get, when you update something via the API, send back what you got

    It's not difficult building the queries. I just need to remember to pass the work down to the client vs doing things on my server. In fact, I have to remind myself I writing server code today. I need to be mindful of where I am in the process.

    I'm just wondering how well C#'s parser is working and if you should be looking for a better parser.

    I'd spend some time making sure C# isn't corrupting json. I'm having issues with vscode corrupting JSON. C# must parse/ stringify JSON properly without inserting any non-printable characters.

    I don't dread querying the API, I did dread it in PHP because the json parser was garbage. Getting a good C# object is key when using the OS api.

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 214
    billy2 said:
    A lot of the api is like this, when you want something you'll need to build 5 queries to get your answer. Lately I've been passing this compute down to the client and letting your computer crunch the data vs. my server. I don't want my server doing this work. A server should just be a traffic cop sending an object to a client. The client in turns asks the server to get more data from OS. 

    Using localhost, you don't have a server. Your local computer will be crunching the objects for the next query. If the API supplies everything from onshape, it's going to be complicated. You want this version of a partstudio when using this version of a feature script, it's all there and is accessible through the API. I think we want this.

    I couldn't figure fstable out either. The good news is there appears to be some support for the API now. @Paul_J_Premakumar thanks for the explanation. To me, the nomenclature is difficult like what does "partsBound" mean? There's many things in the API that aren't user facing and we programmers have no idea what these things mean. Holy crap! there's never been a manual for the API in the past.

    A great manual would have an example for each function call like the one created above. Please create a link in glassworks for each function call in the api like the one above. Please don't make us fight the forum searching for answers.

    The example above is amazing, I just don't want to have to search the forum for the answers.


     You are right, this information should be in glassworks. We are working towards, improving our glassworks documentation and samples.  In this specific example "partBounds" is the type of the custom table type, Alan is looking to evaluate via the API. 
  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    C# from JSON works pretty smooth.  In the sample app on github, it only has some of the APIs covered, but these it converts directly to and from C# class-based objects.  Something like 

        Document d = message.ReadJson<Document>();

    Not actually this line but it is that easy.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    Cool, that's a hard thing to debug if it's not perfect.

    My other point is that you'll get really good at using d in ways never done before and you'll access the object parts as needed easily. The important thing is to keep d intact. One of these days you'll want to update OS and you'll send the modified d back to OS. It doesn't work any other way.

    Dancing through the API will be necessary and the best method I have found, and Bill S. also, is to use the api explorer. You'll get good at using the api explorer. You'll learn most of the calls and build an understanding where things are located.

    I haven't done much with the API and feature script calls. It's kind of scaring because feature script is somewhat limiting in that it only works in a partstudio. With the API, you can open it up to everything. I can't even imagine what it's capable of doing.

    Drop me a PM with your phone number, I'd like to see what you're up to.

    Good luck,
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    @Paul_J_Premakumar I worked with Steve Lamboski? in the beginning and figured out a lot of stuff. You guys have been very helpful in the past and I appreciated it.

    But..... Thanks for the manual, yahoo! We're going to have some documentation.

    Glad you're on board!


Sign In or Register to comment.