Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape, CAD, maker project and design.

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.

Is there a getAllVariables()? Specifically Configuration Variables.

leon_pootleon_poot Member, Developers Posts: 87 ✭✭
edited October 9 in FeatureScript
Is there a way of accessing a list (map) of all (configuration) variables in a Part Studio?
Perhaps a way of accessing the input of the build(config) function?

Basically a
getAllVariables()
is what I'm after, in the spirit of
getAttributes(...qEverything()...)


"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

Answers

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers Posts: 396
    There is currently no such function. The end user can, of course, explicitly set any quantity or isAnything input to #myConfigVariable. This is the preferred, non-magical way of using those values. If you'd like a magical way, please submit an improvement request with your use case :smile:

    If you're just looking to find a single variable (or any of a small set of known ids) which may or may not be set, note that you can say
    const possibleValue = try silent(getVariable("possibleId"));
    This will benignly set possibleValue to undefined if the variable doesn't exist.

  • leon_pootleon_poot Member, Developers Posts: 87 ✭✭
    And here I was, hoping for a little Abracadabra... (fun fact: that term is, in written form, likely over 1700 years old).
    Jokes aside it can't be impossible to make this magic happen since all the info is there, and is readable under "Show Code". I'll submit an IR.

    As Arthur C. Clarke puts it so eloquently:
    "Any sufficiently advanced technology is indistinguishable from magic"


    "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.