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.

access variable context of another feature

adamohernadamohern Member, OS Professional Posts: 216 PRO
I'm using a FeatureList parameter to select a previously-created feature. Is it possible to look into that feature's context to access its definition variables and/or internal feature id's within the feature?

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited May 2016
    You can assign variables to the context with setVariable and retrieve them with getVariable. Note that these values can also be accessed by a user using #varName

    You can also attach data to entities as attributes.

    For your case, I'd probably use setVariable and getVariable using the featureId to store the relevant data.
    if (isTopLevelId(id))
    {
        setVariable(context, id[0] as string, data);
    }

    Note the isTopLevelId check. If any variable-setting features get patterned, they'll have nested ids which fail the check, and also won't be selectable via feature pattern.

  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    What about accessing a query from the definition of the other feature? Is that possible?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    If the feature stores the query, sure.  Otherwise (for like the query input to an extrude feature), not yet, but I would like it to be accessible.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.