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.
Using fstable
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.
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
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 |
www.virtualmold.com
Comments
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:
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
@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.
www.virtualmold.com
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.
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.
Document d = message.ReadJson<Document>();
Not actually this line but it is that easy.
www.virtualmold.com
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,
But..... Thanks for the manual, yahoo! We're going to have some documentation.
Glad you're on board!