<p>Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.</p></p><strong>First time visiting? Here are some places to start:</strong></p><ol style="list-style:inherit;margin-left:25px;"><li>Looking for a certain topic? Check out the <a href="https://forum.onshape.com/categories">categories filter</a> or use Search (upper right).</li><li>Need support? <a href="https://forum.onshape.com/post/question/community-support">Ask a question</a> to our <a href="https://forum.onshape.com/categories/community-support">Community Support</a> category.</li><li>Please submit support tickets for bugs but you can request improvements in the <a href="https://forum.onshape.com/categories/product-feedback">Product Feedback category</a>.</li><li>Be respectful, on topic and if you see a problem, Flag it.</li></ol><p>If you would like to contact our Community Manager personally, feel free to <a href="https://forum.onshape.com/profile/6/LouGallo">send a private message</a> or <a href="mailto:lgallo@onshape.com">an email</a>.
</p>
</p>
Can Custom Properties set by FeatureScript be numbers?
Sam_Schlageck
Member Posts: 19 ✭✭
I have a "Quantity" custom property that populates a field in our drawings to indicate how many panels of a certain size need to be fabricated.

I would like to drive that "Quantity" property with a variable from a variable studio - however when I set up my FeatureScript to assign the variable I keep getting this error message - unless I set up the "QTY" variable as a string

Is it possible for FeatureScript to assign numbers to custom properties - or can it only do strings?

I would like to drive that "Quantity" property with a variable from a variable studio - however when I set up my FeatureScript to assign the variable I keep getting this error message - unless I set up the "QTY" variable as a string

Is it possible for FeatureScript to assign numbers to custom properties - or can it only do strings?
0
Comments
-
According to the docs (https://cad.onshape.com/FsDoc/library.html#setProperty-Context-map), the value of a custom property must be a string. Can you use stringToNumber on the receiving end?0
-
Hey Sam,
setting an integer custom property with featurescript is a bit unintuitive, you have to convert the number to a string in order to set it. But the value will be an integer when you look at it in your custom properties.
I have a sample here:
https://cad.onshape.com/documents/442da55b8784fa545559a439/w/ff690aea9b839abc2f34fde7/e/ab381bcc8f8e10e1af663ecc
You can see that wrapping the quantity variable with toString() is all it takes to make it work.
www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1 -
I did a "toString(QTY)" value for the custom property value - works!
Thanks for your help!0


