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.

Variable Hole Count With Calculated Spacing

Member Posts: 4 EDU
edited July 13
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?

• Member, Onshape Employees Posts: 169
edited July 14
A curve pattern and a couple of variables can do this for you. In the attached doc you can follow the steps I took:

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.