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.

FeatureScript question. allowing variable names with/without spaces

jelte_steur_infojelte_steur_info Member Posts: 611 PRO

In Onshape's native variable features, there's a verifyVariableName feature that a.o. checks if variable names already exist as a different type of variable (like query ~).
moreover it will throw an error if it contains spaces, which forces us tot type with dashes or underscores etc (camel, snake, Pascal or kebab or something made up).

I programmed a setQueryVariable function into another function the other day and found that at least query variables work perfectly well with spaces in the names.

Why is the native Onshape feature this strict? (making typing a name less intuitive).
In what circumstances could a custom feature cause issues when I'm not as strict?

Answers

  • Konst_ShKonst_Sh Member Posts: 109 PRO

    Using spaces in identifiers would screw up expression parsing, you can make multiword descriptions for variables, but keep the name short enough to let it be conviniently used in expressions

Sign In or Register to comment.