Feature request: cosmetic threads for Hole feature

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request: cosmetic threads for Hole feature

Post by chrisb »

I have added two files to the first post for comparison purposes.

Recompute times here:
RealThread: 20 sec.
CosmeticThread: 5.5 sec.

To prepare the feature request as good as possible we may test for different shapes of the cosmetic thread to optimize look and feel.

I also add the code of a small macro doing a full recompute and displays the time. In the code you can switch btween process and elapsed time, for the comparisons above I took the latter. With the keyboard shortcut for the last macro it is convenient for comparisons.

Code: Select all

OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.20.28774 (Git)
Build type: Release
Python 3.9.12, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: C/Default (C)
Installed mods: 
  * FC_SU
  * DynamicData 2.46.0
  * FeedsAndSpeeds 0.4.0
  * fcgear
  * Manipulator 1.4.3
  * fasteners
  * sheetmetal
  * ExplodedAssembly
  * Curves 0.3.0
  * Assembly4 0.11.12
Attachments
timeToRecompute.py
(626 Bytes) Downloaded 25 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: Feature request: cosmetic threads for Hole feature

Post by user1234 »

adrianinsaval wrote: Thu May 12, 2022 9:53 pm problem is you need to add support for that on the rest of the PD features which increases the complexity,
Yes, that is true. But if that be handled, the 2D lines for that in TechDraw are given.


adrianinsaval wrote: Thu May 12, 2022 9:53 pm I know it's not common to make pockets or other features that interfere with an existing hole but when it happens we can't have a floating thread in the middle
They are not interferencing/intersecting, this are CompSolids (multiple solids). They are not independents solids, they are common solids. They share the common faces, edges, points, .....

I added the outer thread a transparency (trough alpha channel), which give a good visible indicator. The problem on my computer is, that the alpha channel is glitching a little bit, the normal transparency works way better, but not able to give only discrete faces, edges and points at the moment.

1.png
1.png (37.67 KiB) Viewed 1164 times
thread.FCStd
(69.33 KiB) Downloaded 34 times


Greetings
user1234
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request: cosmetic threads for Hole feature

Post by chrisb »

user1234 wrote: Thu May 12, 2022 8:43 pm I would do it with CompSolids, because it also can used in 2D. See https://forum.freecad.org/viewtopic.php ... 21#p452221
Using these in TechDraw would be more than the icing on the cake!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature request: cosmetic threads for Hole feature

Post by chrisb »

I have done a zigzag cosmetic thread. Without the MultiPattern it is as fast as the squared based on Shalmeneser's model.
When I did it with the same technique with the MultiPattern, then it was nearly as slow as the real thread, so there is probably quite some more optimization potential.
Attachments
CosmeticThreadZigZag.FCStd
(116.68 KiB) Downloaded 26 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: Feature request: cosmetic threads for Hole feature

Post by user1234 »

chrisb wrote: Thu May 12, 2022 11:33 pm Using these in TechDraw would be more than the icing on the cake!
I do not know, what this means.


chrisb wrote: Thu May 12, 2022 11:46 pm I have done a zigzag cosmetic thread.
I see here 2 issues.

- It creates many cone elements, faces, edges. This means, that is compute intensive and can (maybe) take more computing time, memory and space. But it is not that big issue. The biggest issue is the next.

- When you have assemblies with an inner and outer thread, the position (along the thread axis) is not always the same. This means they often will intersect and make some void rooms, if the pitch does not match perfect. Despite it does not look good and could be confusing, deviating this in 2D with the OCCT will be extremely hard (or maybe other CAD kernels, since many do not like too much intersecting volumes).



Just marking the thread faces with a color will also do the job, also this is not very unusual.


Greetings
user1234
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Feature request: cosmetic threads for Hole feature

Post by adrianinsaval »

user1234 wrote: Thu May 12, 2022 11:03 pm They are not interferencing/intersecting, this are CompSolids (multiple solids). They are not independents solids, they are common solids. They share the common faces, edges, points, .....
do PD features consider it a single solid and operate normally on it though? That's my point
User avatar
KurtF
Posts: 161
Joined: Fri Mar 04, 2022 7:36 pm
Location: North Carolina, US
Contact:

Re: Feature request: cosmetic threads for Hole feature

Post by KurtF »

Chris, I just checked out your thread samples- very cool. I took the same approach, using a simplified thread profile (3-pt triangle) to replace the full one, and gained some speed. But the largest gain came when I started substituting the real pitch value with 5.0mm for the cosmetic thread. Far less cpu (and I'm assuming file storage) to thread a candy-cane.

Cosmetic Thread.jpg
Cosmetic Thread.jpg (485.65 KiB) Viewed 1080 times

I thought about using color/transparency to display disabled thread threads too... but I'm convinced FC together with user customizations is already using every color on the spectrum. :-)

EDIT: Created 3 threads 10 x 1.0 x 15mm. Real threads saved filesize: 723K. Cosmetic: 167K.

EDITEDIT: Oh, and just think of the documentation! "...for performance with large assemblies click the thread toggle button to turn all threads into candy-canes..." Could creating a custom display mode work for your code?

Code: Select all

    def getDisplayModes(self,obj):
        '''Return a list of display modes.'''
        modes=[]
        modes.append("Candy Canes")
May whatever Higher Power you believe in bless the Ukrainians. They are a decent people who never hurt anybody.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Feature request: cosmetic threads for Hole feature

Post by Jee-Bee »

adrianinsaval wrote: Thu May 12, 2022 9:53 pm problem is you need to add support for that on the rest of the PD features which increases the complexity
I don't completly understand why it add more complexity. I don't understand why the (cosmetic )thread needs knowledge about the feature it is created with. it should take care about the shape you want to add it on. As long as that is cylindrical it shouldn't been more difficult if i created it through extrusion, revolve or whatever whatever fancy feature?
adrianinsaval wrote: Thu May 12, 2022 9:53 pm I know it's not common to make pockets or other features that interfere with an existing hole but when it happens we can't have a floating thread in the middle
I have seen it serval times. sometimes (recreating )buy parts have to be changed(shortens) or where holes cross eachother. or lowering the thickness so you can use a smaller screw or bold...
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Feature request: cosmetic threads for Hole feature

Post by adrianinsaval »

Jee-Bee wrote: Fri May 13, 2022 11:06 am I don't completly understand why it add more complexity. I don't understand why the (cosmetic )thread needs knowledge about the feature it is created with. it should take care about the shape you want to add it on. As long as that is cylindrical it shouldn't been more difficult if i created it through extrusion, revolve or whatever whatever fancy feature?
I was talking about the compsolids proposal, AFAIK that's not supported by the rest of the PD features, so adding something like that means everything else has to be modified to know how to deal with it.
User avatar
KurtF
Posts: 161
Joined: Fri Mar 04, 2022 7:36 pm
Location: North Carolina, US
Contact:

Re: Feature request: cosmetic threads for Hole feature

Post by KurtF »

adrianinsaval wrote: Fri May 13, 2022 5:31 pm I was talking about the compsolids proposal, AFAIK that's not supported by the rest of the PD features, so adding something like that means everything else has to be modified to know how to deal with it.
CompSolids! Yay! I just ripped out all the cosmetic thread code from my macro, and instead, for bypass threads, skip the profile sweeping completely and stuff Part.makeCompound([threadlessbody, helix]) into fp.Shape. This works great in my macro environment: 3 Thread Shafts saved with threads: 712K. Saved without: 21K. Disable thread rendering is instant. But it doesn't work and play well with Part booleans. :-(

I confess this thread thread is going over my head, but I hope you folks can integrate this into PD bodies without a major refit.
May whatever Higher Power you believe in bless the Ukrainians. They are a decent people who never hurt anybody.
Post Reply