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.

Options

How to accept wonky strings as featurescript inputs?

imants_smidchensimants_smidchens Member Posts: 63 EDU
edited January 2023 in FeatureScript
Hi! I'm writing a Featurescript that will (hopefully) take an SVG string input, and parse it/convert it into Onshape sketch features, letting users essentially import SVGs through a configuration input. (This would let you integrate configurable logos into your designs, where a user can just upload an SVG in string form, or even have an automated 3rd party application do this through the API!) Unfortunately, the two parameter predicates I had hopes for,
definition.whatever is string
and
isAnything(definition.whatever)

both fail, for different reasons. SVGs contain paired inequalities such as "<path>" but these are invalid string inputs: they just vanish as soon as there's text between two inequality brackets. As far as I can tell, this is true for all string parameter inputs in the featurescript UI, as well as configuration variables set to "text".
The isAnything() predicate can't take an SVG because it's not a featurescript-syntax-approved formula, so that also doesn't work. Enclosing the SVG string with quote marks also doesn't work, since there are nested strings as a part of the SVG, and this would necessitate that users manually replace every " with \" (also not really an option)

Suggestions?

Answers

Sign In or Register to comment.