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.

ThreadLab - Internal/External Modeled/Cosmetic Threads with External Thread Callouts

antlu65antlu65 Member Posts: 59 EDU
edited September 2022 in FeatureScript
Custom Feature: ThreadLab V0.3

A simple custom feature for creating internal/external modeled/cosmetic threads on cylindrical faces. Dave Cowden's excellent ThreadCreator (I believe V3 is the latest version) has been used for years and is the de-facto standard for creating modeled threads, but has sometimes has significant feature regen time. Cosmetic thread implementation is based off of Sebastian Glanzner's Cosmetic Threads feature.

Features:
  • Cosmetic or Modeled threads
  • Thread profiles: ISO Metric, ANSI UTS, ISO Trapezoid (DIN 103), ANSI Acme, Whitworth
  • Optional offsets
  • Optional thread chamfer (lead-in)
  • Customizable thread form
  • Customizable thread name
  • Created threads allow Hole Callouts in Drawing interface
  • Multiple threads per feature invocation, fast feature regen time
Possible features to add:
  • Thread fillets
  • Tapered threads on conical faces (eg. NPT threads)
Demo (V0.2):

«1

Comments

  • antlu65antlu65 Member Posts: 59 EDU
    ThreadCallout functionality wrapped into ThreadLab custom feature.
  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    V0.2: Added ISO DIN 103 (15 degree) and ANSI Acme (14.5 degree) thread profiles with multiple starts.
  • sebastian_glanznersebastian_glanzner Member, Developers Posts: 425 PRO
    @antlu65
    Your FeatureScript is really cool!  :)

    I like how you use the hole callout feature!  B)
    Do you think it is possible to automatically add the diameter of the core hole to the hole callout the drawing?
  • Henk_de_VlaamHenk_de_Vlaam Member, Developers Posts: 242 ✭✭✭
    @antlu65

    This icon   confuses me.

    At my opinion it indicates left handed thread because of the anti-clockwise arrow direction.
    The showed thread in the model however is right handed, which should get a clockwise indication.
    Henk de Vlaam (NL)
  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    @sebastian_glanzner: I had completely forgotten about the hole diameter for internal threads - will add that.
    @Henk_de_Vlaam: Agree, using the orientation icon as I did was a poor choice - will change that.
    Really appreciate your feedback! :smile:

  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    sebastian_glanzner
    I didn't realize you were the author of the Cosmetic Threads custom feature - that's the method I used for cosmetic threads in this script. Wanted to credit that here (and in original post). Thank you!
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    yes! this is really cool. I'm adding it to the toolbar.
    Evan Reese
  • eric_pestyeric_pesty Member Posts: 1,947 PRO
    That seems really cool! I'll have to play with it a bit more.
    One thought: how about a middle ground "schematic" option? I.e. just a linear pattern of circular grooves instead of the full helix?
    This can be a good intermediate that looks more "real" without incurring the high "cost" of swept helical cuts. 
  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    @Evan_Reese: Thanks! :smile:
    @eric_pesty: Thanks! And that's a cool idea - will think about adding that as well!

  • sebastian_glanznersebastian_glanzner Member, Developers Posts: 425 PRO
    edited September 2022
    @antlu65
    Thank you to for creating ThreadLab FeatureScript! I'm glad my cosmetic thread FeatureScript is useful to other Onshape users.
    I hope that some day Onshape will implement a native way to display and model threads.

    I also made another FeatureScript where you can change the level of detail of the external thread:
    https://forum.onshape.com/discussion/16744/new-featurescript-external-thread-2d-3d

    External Thread - FeatureScript:
    https://cad.onshape.com/documents/190ed381cc4d7d3644e4459b/w/69776a82bab11838fe161502/e/dfca34f846d7250bee8c4f46

    Internal Thread - FeatureScript::
    https://cad.onshape.com/documents/41326316775b71b4c76d71c2/w/bdab4a37f9f548848e230c4d/e/113d4ba1dc7ffa295c02a7d3


    I also have a third option to leave the face clean (no cosmetic or 3D thread). This is useful for me when I export step files:

    In the "2D" option (cosmetic thread) I tried to simulate the thin line by revolute and cut away a thin rectangle. 
    This is useful for 2D drawings.


    I really like your ThreadLab, because you have internal and external thread in one script and it is so cool how you used the hole callouts!

  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    @antlu65
    Thanks again for making this feature available. I finally got around to playing with it and it's awesome. No pressure to implement any of this if it doesn't make sense to you, but I do have a few thoughts that are mostly centered around my personal use-case for this feature which is 3D printing:
    • If I select mismatched holes, it fails. The reason this is important with printed parts that have to mate, because I want to add my clearances to the male and female parts ahead of time, then add threads, but that means they will always be of different diameters. It seems like you may be limiting it to prevent people from doing it by mistake, but another solution would be to give a warning that they are mismatched, and name the feature "Various" or something like that.

    • I noticed the number of "Starts" on the acme thread is limited to 4. Maybe this is also to conform to a standard, but again, I'm mostly interested in a very flexible tool. I don't see a reason to limit it, unless the feature will literally fail with 5 starts. I could make a steep lead screw, for example. If you want to keep it to a spec, you could always provide a warning message to the user, and let them choose what to do about it. Likewise, I might enjoy being able to add multiple starts to standard thread types, even though they aren't to the spec, because I might not just want to use this feature for threads. I could use it to make textures and aesthetic treatments on cylinders too. I know it's not your core use-case, but at least making the feature open for people to play with could be nice. dryspin lead screw technology - igus Blog
    • Since I'm creating threads to print and use, having a lead-in on them can be really helpful. It's a pain to model it manually since I either need to extrude cut with draft or sketch a triangle and revolve cut it. Automating it here sounds helpful.
    Rule of Thumb for Lead Thread Length
    Evan Reese
  • antlu65antlu65 Member Posts: 59 EDU
    @sebastian_glanzner
    Very cool, thanks for linking these! I'll add a "Blank" option to leave selected faces unchanged.

    "In the "2D" option (cosmetic thread) I tried to simulate the thin line by revolute and cut away a thin rectangle. 
    This is useful for 2D drawings."
    If you get a chance, could you elaborate on this? I don't understand what this additional line is used for.
  • antlu65antlu65 Member Posts: 59 EDU
    Evan_Reese
    Really appreciate the feedback! Definitely helps identify poor assumptions I've made and helps me understand real workflows and use-cases. You make a great point emphasizing flexibility over hard restrictions on feature inputs - I'll make those changes and leave it for the user to decide.

    "...I want to add my clearances to the male and female parts ahead of time, then add threads..."
    Would it be useful if the feature gives the option of applying user-specified offsets to the selected faces - or do you prefer to enter them manually? Curious as to your preferred workflow. In any case, will remove the restriction on having selected faces be same diameter.

    "I noticed the number of "Starts" on the acme thread is limited to 4"
    Will remove this restriction.

    "Since I'm creating threads to print and use, having a lead-in on them can be really helpful."
    Could you link a simple example of this? I'm not familiar but would like to implement it.
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    @antlu65
    If there's one thing I've learned in writing features I've written, it's that to maintain a simple enough feature, with a clear vision, you cannot accommodate everyone who has an idea or improvement request (that being me at the moment). If you think it makes sense, go for it, but I also won't feel bad if you don't think it's right for your feature. I'll make an example with a lead-in tomorrow sometime, and let you decide if it fits.
    Evan Reese
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    Here's an example of a few ways to manually model thread lead-ins or chamfers or whatever you'd like to call them. It makes it easier to actually line up and engage the threads. Note that the orange highlighted faces would actually go down into the hole. These are backward just so you can see them.
    https://cad.onshape.com/documents/01860d68bcc294234ae3e65f/w/876191bbd7159797fe97f02b/e/165952b0d326f18bd1f57550


    Evan Reese
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    antlu65 said:
    Would it be useful if the feature gives the option of applying user-specified offsets to the selected faces - or do you prefer to enter them manually? Curious as to your preferred workflow. In any case, will remove the restriction on having selected faces be same diameter.
    To answer this, I'm not completely sure till I try it, but I feel as though I'd rather add my clearances ahead of time. Here's my current thinking on that:
    • There are a lot of ways to add clearances (in the sketch; with a move face; by just entering a slightly bigger value in the hole feature; in a boolean operation; etc). I might use any one of these techniques.
    • Adding clearances ahead of time makes it easier to decipher the design intent later when returning to an old model or if someone else on our team needs to edit it later. If it's all done in a do-everything feature, it's tougher to tell where, how, and why it was added.
    • When coding my own features, I have found myself getting myopic and trying to make one feature do too much, but it's important that custom features are designed to exist in the greater context of a whole chain of other features, instead of doing everything in one go. I try to stick to the single core purpose of the feature and let other features do some work too.
    Evan Reese
  • S1monS1mon Member Posts: 3,039 PRO
    I haven’t dug into Threadlab yet, but clearances for threads aren’t just for 3D printed parts. Machined threads in metal need some clearance to actually work, it’s just much smaller.

    https://www.calqlata.com/productpages/00042-help.html
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    S1mon said:
    I haven’t dug into Threadlab yet, but clearances for threads aren’t just for 3D printed parts. Machined threads in metal need some clearance to actually work, it’s just much smaller.

    https://www.calqlata.com/productpages/00042-help.html
    Definitely. I think of them as slightly different problems to solve because printed threads have variables that are unique to me (which printer and settings I use), whereas clearances for standard threads are already established. For the first case, I'd prefer to add it myself manually, but for the second case, a dropdown for thread class would probably be simpler to use so I don't have to reference a chart. However, it would make the feature even more complex than it is, and I'm not sure what value I'd personally get from this capability. I'd like to hear other's opinions. In my case, when making 3D threads, It will almost never be to model two off-the-shelf things that need to mate. One will almost always be printed, for example I might print an M2 thread into a part and plan on using an M2 screw later, in which case, I still need to tweak the clearances manually to account for my personal print setup.
    Evan Reese
  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    @Evan_Reese

    "If there's one thing I've learned in writing features I've written, it's that to maintain a simple enough feature, with a clear vision, you cannot accommodate everyone who has an idea or improvement request"

    "When coding my own features, I have found myself getting myopic and trying to make one feature do too much, but it's important that custom features are designed to exist in the greater context of a whole chain of other features, instead of doing everything in one go. I try to stick to the single core purpose of the feature and let other features do some work too."

    Sage advice - I am certainly guilty on these points! It's become obvious that I didn't have a clear vision for the feature before I set fingers to keyboard. The result appears to be a hammer in search of a nail.

    Will release a new version that incorporates some of the earlier suggestions in this thread.
  • antlu65antlu65 Member Posts: 59 EDU
    edited September 2022
    Updated to V0.3

    Link: ThreadLab
    • Removed restrictions on thread starts.
    • Added flip manipulators for individual selected faces.
    • Added Whitworth thread to preset thread profiles.
    • Added option for creating thread chamfer / lead-in.
    • Added option for setting shaft/thread offsets.
    • Added option for user to input custom string for thread name.
    • Added option for user to define custom thread profile.
    • Added 'BLANK' mode (cosmetic/modeled threads is disabled, but offset/chamfer remains active).

    --------

    * Flip manipulator for each selected face. User has finer control and is able to reverse thread direction on individual faces. Thought this was a cute feature, but not sure if it's more distracting than useful.



    * Whitworth (rounded) preset thread profile. Rounded tip and root, with 55 degree included angle. Slower regen time than straight thread profiles.




    * Option for thread chamfer / lead-in. User may adjust angle and radial distance of chamfer, feature will modify shaft and thread geometry accordingly.



    * Option for offset on shaft and thread. User may specify offset distance for external and/or internal faces, feature will modify faces and threads accordingly. External offset will reduce shaft size, while internal offset will increase shaft size.




    * Option for user-input thread name.




    * Option for thread profile customization
    . User may specify thread angle, rounded/straight, and tip/root reduction factors.


    * Removed restrictions on thread starts. Because it's a free country!
  • michael_zeaglermichael_zeagler Member Posts: 106 ✭✭✭
    This thread chamfer is fantastic. It's one of my favorite usability details and I've included it manually on so many parts for years.
  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    This is super awesome - you clearly put a ton of effort into this, and I'm super impressed by the level of detail and quality you've managed to achieve.

    In terms of manipulators, you may wish to consider updating the flip logic so the base of the arrow is always at the start of the thread facing into the cylinder, as this behavior might be a little bit more intuitive to users/consistent with std manipulator styles.

    export function OnManipulatorChange(context is Context, def is map, manipulators is map) returns map<br>{<br>    for (var id, m in manipulators) {<br>        // Whenever a manip is clicked, flip status also changes<br>        def.faceData[stringToNumber(id)].flipped = !def.faceData[stringToNumber(id)].flipped;<br>    }<br>    return def;<br>}<br><br>function DrawManipulators(context is Context, id is Id, faceDescs is array, def is map)<br>{<br>    // Add a flip manipulator for each target face.<br>    for (var i = 0; i < size(faceDescs); i += 1)<br>    {<br>        addManipulators(context, id, {<br>                    toString(i) : flipManipulator({<br>                            "base" : faceDescs[i].cSys.origin,<br>                            "direction" : faceDescs[i].cSys.zAxis,<br>                            "flipped" : false<br>                        })<br>                });<br>    }<br>}
    I could also see a world where there isn't one manipulator for each face (akin to the onshape hole feature), but since you already have it (and even implemented query stabilization, which is awesome!), I don't really see any particular reason to remove it.

    In any case, super great work - I'll definitely be recommending this to everyone I know as the new go-to way for making threads in Onshape.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    This is one of my new favorite features! Thanks for sharing.
    Evan Reese
  • eric_pestyeric_pesty Member Posts: 1,947 PRO
    This is great,
    The only thing I can find to complain about is that it would be nice to add some "imperial" data to the custom "lengthbounds". For example right now I added a chamfer in imperial units and it defaulted to 1" which was way too large and cause the feature to fail (until I noticed and changed it to .05).
  • kees_bijkerkees_bijker Member Posts: 89 ✭✭
    Oh my goodness, you guys are awesome. But, a real onshape starter like me does not yet know how to actually implement this into my existing drawings. Where can I find the learning material that shows me instructions on how to take this featurescript and put it into my existing drawing? It is one thing playing with this in the copy of the document, but to actually implement it is a whole other thing.
    Please a hint as to where to find some instructions on this?
  • eric_pestyeric_pesty Member Posts: 1,947 PRO

  • kees_bijkerkees_bijker Member Posts: 89 ✭✭


    Hello and once again you come to my rescue. Learning so much about onshape here, I am starting to wonder if it is legal ;-) One thing I noticed is that the two scripts on external and internal threads are not containing the same options for unified threads.
    I have to 3d print 3/8-24 UNF on both shaft and a nut, but in the internal threads the 3/8-24 is not included.
    Is there another source where to find this thread being modeled for printing?
    Or do I have to learn to write the script myself? This is a serious question, as I already code in Openscad, it does not look all that different in most instances. But it will take time.
  • eric_pestyeric_pesty Member Posts: 1,947 PRO
    I am not familiar with the details of what is included or not (or why...). You could try the "thread creator" custom feature... It doesn't have built-in offset etc but I think it will accept more "freeform" thread dimensions.

    https://cad.onshape.com/documents/6b640a407d78066bd5e41c7a/v/845d049782179b9faee8b6e6/e/c953720c264ce001f1a82dc1?jumpToIndex=1368

    As a side note I don't know how much of the training you have gone through but even if you know how to use "CAD" in general it helps to actually go through the "basic" stuff as it goes over Onshape specific things like interface and how to do things like this (eg. add a custom feature to your toolbar)
  • felix_jenfelix_jen Member Posts: 2
    Is there any chance we'll be able to get threads on tapered faces? Hoping to model in an NPT thread. 
Sign In or Register to comment.