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.
Store custom hole sizes for later
sebastian_theilenberg
Member Posts: 3 EDU
Hi,
I frequently use custom hole sizes for the hole feature, mainly when modeling holes for threaded inserts. I only use a few sizes, though, so the custom numbers are almost always the same. Nevertheless, I always have to look them up in a table, again, and then type them in manually (hoping not to make a mistake). Then I have to rename the feature so that it describes what it represents (e.g., insert M4 …). I used to work with Solidworks, and there I was able to create custom libraries for hole standards, but I couldn't find anything like this for onshape.
My question is, what is the current best way to deal with this? Is there a cool feature script I overlooked? If there is currently no solution to this, would it in principle be possible to make a feature script that internally uses the hole feature, so that callouts etc still work?
Comments
My boss used to have a custom hole table for counterbores we used in Solidworks and was instructing the team to manually update their hole features to match the dimensions of those previous internal standards. He asked me to look into a way to save custom hole dimensions with the default hole tool and ultimately I determined that with the way it's been implemented in Onshape there's not really an easy way to create custom standards for re-use. My next step was to show the boss that I've been using the ANSI counterbores for the last 6 years and the aesthetic difference between the custom size and the globally agreed standard size has skated by unnoticed and that we should just be using the in-built standards for speed, ease of use, and me not needing to maintain a custom database of fastener libraries for holes.
For custom inserts or other non-standard hole geometry my recommendation is to use the 3d printed insert custom feature or the point derive feature.
Derek Van Allen | Engineering Consultant | MeddlerYou could create a variable studio with the required values but you would still have to import this in the document you are working in and then set your hole to use the variables so still quite a few clicks.
In general though, this is what Featurescript is meant for. It sounds like this might actually be what you need (or even ask the author to add your specific type in there!)?
https://forum.onshape.com/discussion/27617/custom-feature-heat-set-insert-threaded-inserts-for-3d-printed-parts
FS is: https://cad.onshape.com/documents/515b197dfe1d80762df566c7/v/9d430c9ea16e7b48cd715f89/e/d5afb15680416dc5cb24925c
And if not, it should be fairly simple to modify this FS to create your own "library" to it.
@sebastian_theilenberg I don't think you're alone here. There is a Variable Hole feature by @Alex_Kempen that can set a hole spec, then can be used in all things downstream, and edited all in one place. The one thing I've not figured out with this custom feature is how to override just one parameter when using it, which makes it a little tricky to use. I've got half a mind to make a version of it for that use case, but not sure when I would.
In the meantime, I would reiterate that you can absolutely make a modified version of the hole feature for your common custom inputs. Your feature can just be a UI with the right options (which you can copy and modify from the existing hole feature), then send all of that data (the "definition") to the hole() function, which is the native hole feature itself. You can still leave all of the geometry and tagging to that function. The business end of your feature could literally just be
{hole(context, id, definition);};The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
@EvanReese ,
I was actually considering doing something like this but kind of hit a snag with the "volume" of the definition map for the hole feature…
Any tip for how you would go about providing the required values for such a complicated feature?
I tried creating a feature with the parameters I wanted and somehow get the map for that from the "view code" in my part studio and paste that in my code.
I did manage to get a feature that creates a hole (after fixing the map to include a location and scope), but but figuring out how to change the actual hole parameters looks var from simple!
@eric_pesty
I was imagining replicating and modifying the actual UI, which is what writes everything to the definition. If you want a simpler UI with certain definition fields hard coded in, you can do that too. Remember that the hole() function is just looking for the feature definition (which is just a map of key/values). Normally the definition is set by all of the UI elements of the hole feature, for example
definition.oppositeDirectionis a checkbox, and will be set by the user. However you can just as easily not have it in the UI, and later in the feature execution writedefinition.oppositeDirection = false;to add it to the definition manually. The Hole feature code precondition also includes a whole set of "default" params starting on row 910 (as of now), which is a great starting point to know what fields must be set and what you might set them to.You could try not declaring them all, and seeing what error message you get from hole(), It should tell you what param caused the issue then you can fix them one by one till it works. Or maybe you just wanna do them all and give them a value.
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
@EvanReese ,
I was trying to avoid duplicating the hole UI as it's 100s of lines of code with lots of "ifs" so it's really not trivial to make changes to it!
I think the hole feature has to be one of the worst for this! It does all sort of "weird" stuff with tolerances and I'm just generally struggling to figure out what's going on!
I have been manually setting parameters as you describe, the challenge being figuring out all the ones I need for the type of features I am trying to make and just banging my head against endless "precondition fail".
I'll see if this list of "defaults' is going to help! I was trying to do something "quick and dirty" but I'm already about a full day into it! I think I'm making progress but it's definitely slow!