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.

API Sketch Geometry ID

Lucas_CrupiLucas_Crupi Member Posts: 5 EDU
When calling the /partsudios/d/{did}/{wvm}/{wvmid}/e/{eid}/features from the REST API, there are some geometry references in the form of three characters, eg. "geometryIds": ["JMF"]

I have been able to find the ID of edges using /partsudios/d/{did}/{wvm}/{wvmid}/e/{eid}/bodydetails however, when the referenced geometry is an entity within a sketch such as a line, I cannot seem to find the appropriate API call. 

Any help or resources are greatly appreciated.

Best Answer

Answers

  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    I believe "entityId"  is what you need.  See fragment below.

      "features" : [ {
        "type" : 151,
        "typeName" : "BTMSketch",
        "message" : {
          "entities" : [ {
            "type" : 4,
            "typeName" : "BTMSketchCurve",
            "message" : {
              "geometry" : {
                "type" : 115,
                "typeName" : "BTCurveGeometryCircle",
                "message" : {
                  "radius" : 0.05423578839196134,
                  "xCenter" : -0.03895397484302521,
                  "yCenter" : -0.03339579701423645,
                  "xDir" : 1.0,
                  "yDir" : 0.0,
                  "clockwise" : false
                }
              },
              "centerId" : "pUzfMw2i2Kly.center",
              "internalIds" : [ ],
              "isConstruction" : false,
              "parameters" : [ ],
              "isFromSplineHandle" : false,
              "entityId" : "pUzfMw2i2Kly",
              "namespace" : "",
              "hasUserCode" : false,
              "nodeId" : "M3H5t/In4rdlnyQ+z"
            }
          }
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    I see the problem here: Extrude features reference geometry by geometryIds, and while we can get these ids for bodies, there's no id presented for sketch elements.  So here's a feature definition:

    {
        "type" : 134,
        "typeName" : "BTMFeature",
        "message" : {
          "featureType" : "extrude",
          "featureId" : "FukfxxLNUGr2Ytg_0",
          "name" : "Extrude 1",
          "parameters" : [ {
                  ... 
               {
            "type" : 148,
            "typeName" : "BTMParameterQueryList",
            "message" : {
              "queries" : [ {
                "type" : 138,
                "typeName" : "BTMIndividualQuery",
                "message" : {
                  "geometryIds" : [ "JGC" ],
                  "hasUserCode" : false,
                  "nodeId" : "FhjpxqVvrJ9zlPM"
                }

    and the arc (or face?) JGC is defined in the program by sketch entity "pUzfMw2i2Kly", but there's nowhere in the API to identify this link.
    But if I construct an extrude using a body face as reference, that reference can be found in the bodydetails call.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    Answer ✓
    The documentation has the resolution, thought it's a bit weird:

    Feature List API | Onshape Developer Documentation (onshape-public.github.io)

    We ask Onshape to run a featurescript query, get the geometry ID as a result, and that there is your geometryId.


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

  • alexander_koppelalexander_koppel Member Posts: 5
    The documentation has the resolution, thought it's a bit weird:

    Feature List API | Onshape Developer Documentation (onshape-public.github.io)

    We ask Onshape to run a featurescript query, get the geometry ID as a result, and that there is your geometryId.


    I have tried this method, and it doesn't seem to work. I was able to get the geometryID of a "part of a sketch", but can't get the geometry of the only edge in that sketch. For context, the sketch I am using has featureID:Fd5TnWYq9UpUQe5_0, only consists of a single line, and is named "Revolute Line".


    The script that returned the "part of the sketch": 
    "script":"function(context is Context, queries){return transientQueriesToStrings(evaluateQuery(context, qCreatedBy(makeId('Fd5TnWYq9UpUQe5_0'), EntityType.BODY)));}"

    I know this as I tried to use the returned geometryID as a revolute axis:



    Then I tried specifying, GeometryType.LINE, and got an empty return value, the script:
    "script":"function(context is Context, queries){return transientQueriesToStrings(evaluateQuery(context, qGeometry(qCreatedBy(makeId('Fd5TnWYq9UpUQe5_0'), EntityType.BODY),GeometryType.LINE)));}"

    Which returned:
    {
      "console" : "",
      "notices" : [ ],
      "result" : {
        "type" : 1499,
        "typeName" : "BTFSValueArray",
        "message" : {
          "value" : [ ],
          "typeTag" : ""
        }
      },
      "serializationVersion" : "1.1.23",
      "sourceMicroversion" : "183175352bf8cf2f4fb64556",
      "rejectMicroversionSkew" : false,
      "microversionSkew" : false,
      "libraryVersion" : 1803
    }
Sign In or Register to comment.