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.
Variable Hole Count With Calculated Spacing
eric_bergquist436
Member Posts: 5 EDU
I wasn't able to find a good answer searching the forum, so hopefully this hasn't been a repeated question. I'm creating a configurable enclosure that is assembled with fasteners. I have two requirements for the fastener holes: 1) the end holes must be a consistent distance from the back and front of the box and 2) the holes spacing has to be less than or equal to 4". How would I approach creating a hole pattern that selects the least number of holes that meets the spacing criteria? Then, how would I constrain the final positions of the holes so that the previously selected number of holes are spaced equidistant between each hole and with the right end spacing?
Tagged:
0
Answers
1. Create variables for inset and target_pitch. Bonus points: You might want these to be a function of the diameter of the hole you are drilling...
2. Create a sketch for the run of the fasteners. Apply the #inset variable to this sketch.
3. Create a measured variable run_length for the length of that sketch you just created
4. Create a variable (variable type = Number) for num_fasteners, and set it to this expression: ceil(#run_length/#target_pitch)+1
5. Create a hole feature located at the end of the sketch
6. Make a Curve pattern, set to feature pattern pick the hole and then pick the sketch line for the run of fasteners. Set the instance count to #num_fasteners
Optional. As a final check you can make a new variable actual_pitch and set expression to #run_length/(#num_fasteners-1) If i've done my math right, this will always be less than or equal to your target pitch.
https://cad.onshape.com/documents/319af4e2fe8270976e36fbc4/w/897efd4ce9acaeb94cdda7c4/e/dbe5451bedacc504a63e9435
PS: this took longer to type than actually make the features, however this is something that I've needed enough to warrant making my own custom feature to do a bulk of the steps (step 3. onwards). In this custom feature I added a "Best fit" option to the standard library Curve pattern feature. However in that feature I used the round() function to get the nearest integer value of fasteners, but I'll go back and add the option to use ceil() so that it does as you require! [edit: I just updated the Best Fit custom feature and added an example in the doc ^^^^ ]