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.

Automatically referencing geometries as input for new feature through API

leon_pootleon_poot Member, Developers Posts: 87 ✭✭✭
Apologies in advance for the abstract problem description. I hope I'll be able to explain it somewhat properly. If not, let me know what information you're missing. My problem is as follows:

Let's say I have two Feature Studios. One which creates a straight line, and one which creates an arc.
  • I need to be able to instantiate these in any given order, and with any number of straight lines or arcs, so for example straight - straight - arc -straight - arc - arc, all in the same Part Studio.
  • Any new added feature must start at the end of a previous one, and be tangent to it too. (I.e. I will need a point and a direction vector as reference).
Now, all of this needs to be done through the API, meaning that I can't have users click in the viewer to select a vertex and an edge; they need to be found automatically. I would also like to keep it to these two Feature Studios, meaning I can't be adding a new Feature Studio for each and every new feature (that'll cost a lot of space in the end).

So that's the setting.
Now the real question: Can I reference vertices and/or edges through the API?

https://forum.onshape.com/discussion/4855/grouping-enum
I have tried to get some inspiration from this discussion, where geometries are referenced by importing another Part Studio and somehow taking all necessary info from the contexts. Something called "Lookup Table" is mentioned, but I haven't been able to figure out how this works.
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless

Best Answers

Answers

  • leon_pootleon_poot Member, Developers Posts: 87 ✭✭✭
    edited October 2016
    Alright so by checking the FeatureList through the API, with a very simple test-case using only an input point to start an opFitSpline with, I get that the input vertex is technically a parameter.
    {
            "type" : 148,
            "typeName" : "BTMParameterQueryList",
            "message" : {
              "queries" : [ {
                "type" : 138,
                "typeName" : "BTMIndividualQuery",
                "message" : {
                  "geometryIds" : [ "IF" ], //This is either "IB", "IF", "IG", etc.
                  "hasUserCode" : false,
                  "nodeId" : "FPJmHLpnWZWV6jA"
                }
              }
    Here the "geometryIds" seems to be the key, which I'd have to put into the message when using the UpdateFeature API (just as one would for a "normal" length parameter for example). How do I know which geometryId to put into the message, or even better: how do I name a geometry in the referenced feature so that I can reference it using that name?

    https://cad.onshape.com/documents/8c428a2d9b209747a8e2b960/w/7f8af340483a59e6f839aa7d/e/b1af2aee4c64b16ca8f1ecd4
    "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless
  • leon_pootleon_poot Member, Developers Posts: 87 ✭✭✭
    So then, could it be that I have to change it to
    "geometryIds" : [ "SOMEKINDOFQUERY" ],
    "hasUserCode" : false,
    with SOMEKINDOFQUERY being a Feature Script query?
    "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless
Sign In or Register to comment.