Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Make a Configuration Variable that can accept a FS array/ any FS expression
ethan_keller924
Member, csevp Posts: 42 PRO
I must be missing something. I'm trying to have one of my configuration variables accept an FS array, but when I attempt to specify the configuration variable type, I just get the options of Length, Angle, Integer, Real or Text. Is there no way to put in a general FS expression? The general PS variables have an "Any" type. Am I stuck using those and abandoning a configuration for this use case? Or is there some workaround?
Tagged:
0
Best Answer
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215Sorry, that is the available set for configuration variables -- there is no Any type for configs.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc1
Answers
Try this:
https://cad.onshape.com/documents/55a3567381b135db132be033/w/5073d5fa95b6d345c88590e8/e/0ea88bfaecbbc3f8dcf094fa
IR for AS/NZS 1100
Thanks for the help! I'm now rather sheepishly realizing there was no need to use regex, I couldv'e just tested for equality between "[" and the char. Regardless, are there any references for what is allowed in FS regex? I'll use your function for now! Looking forward to when functionality like this for strings is built into FS.
The issue you ran into is insufficient escaping, a common pitfall when working with regexes. Specifically, to match the character
you need the regex to be
but to enter the backslash into a string literal (in FS or other C-like languages) you have to escape it, so the string needs to look something like:
The definitive reference is provided here: https://xkcd.com/1638/ Hope this helps.
This stuff looks interesting and I wish I had more time to dig into FS to figure out what you guys are talking about! Good stuff I'm sure.
Does Onshape plan on documenting more examples for users to explore and learn from such as the techniques being questioned and discussed here in these forum threads?
If that configured part studio genuinely needs to depend on an arbitrarily long array of inputs, then you are correct: The best solution is passing and parsing a string.
If you can limit the length to a more reasonable number of length inputs, that will also work. Keep in mind that you should make sure the instantiating code sets the unused values in the same way every time, to make sure you're hitting the cache.