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.
Rounding Calculated Variables to Pattern number of Instances
3D
OS Professional Posts: 52 ✭✭
Can anyone offer any tips for how to round off or convert calculated variables to integers so that the calculated variable works for patterns?
(number of instances patterned?)
Surely this should be fairly simple in FeatureScript but not sure how to approach it.
Surely this should be fairly simple in FeatureScript but not sure how to approach it.
0
Comments
I use these in my Laser Joint feature (lines 565-586) for adaptively setting the number of pins in the joints, if you want to look at some code.
PhD, Mechanical Engineering, Stanford University
https://cad.onshape.com/documents/fe787db77801eacc744b9da0/w/0317627ef816cb97646636d5/e/98d1243380284b60b57a0710
OS FS probably gulping @ green coder...
e.g. Variable #count = 3.45
Instance count: ceil(#count)
Would give you 4 instances.
If the calculated variable is z = 3.142857142857143, reference another variable:
floor(#z) ; value = 3
ceil(#z) ; value = 4
round(#z) ; value = 3 rounds to nearest integer as in example above
and thanks @ilya_baran - while not necessary in this case - is good to know for FS in general.
We didn't change anything so people need more to go on than "it doesn't work" to help -- a shared document with a broken feature or at least a copy-pasted expression.
I didn't think it would be likely OS would have changed anything, however the above wouldn't work - until I realised it was due to the Units included in the Varable by FS MD (Measure Distance) tool.
Divide by mm & it's solved!