Hack of the day: make links more robust for almost free

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!
Post Reply
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Hack of the day: make links more robust for almost free

Post by DeepSOIC »

Hi!
This hack is actually quite old, it's just that today I felt a desire to discuss it.
In Lattice, I have a tool to extract subelements (like Draft FaceBinder and PartDesign ShapeBinder). Some of you may know that. It's called "SubLink"

But what you probably don't know is that I included a small hack to make links to subelements slightly more robust. This is done by counting elements from the end instead of from start, for elements that have indexes closer to the end. Simply speaking, if you select the face with the highest number (say, face 3215 of 3215), that link will remain pointing to the "last" face, when number of faces in shape changes.

Showcase where the tool works almost perfectly:
1. PartDesign Gear
2. PartDesign Pad
3. Extract subelements with Lattice SubLink: top face, for example.
4. change the number of teeth.
Regular links fail miserably. But the hacked link remains reasonable.
sublink.png
sublink.png (45.8 KiB) Viewed 1091 times
The thing is, this hack feels easy to apply to whole FreeCAD. All that needs to be done, I think, is make TopoShape's getSubElement (or however it's called) support reverse counting (negative indexes), and make selection automatically put in the negative index if appropriate. The first is trivial, but the second requires Selection to know, how many elements of the type are available, which may be a tricky problem.
Last edited by DeepSOIC on Wed Jun 22, 2016 9:25 pm, edited 1 time in total.
Reason: fixed title
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Hack of the day: make links more robust for almost free

Post by NormandC »

Hi,

This looks very interesting. More robust links on the cheap gotta be better than what we have right now. But I'm just an end user so I can't know what it would imply internally...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Hack of the day: make links more robust for almost free

Post by triplus »

As a general rule i don't feel we can build robust models based on underlying geometry with changing topology. Therefore i would rather introduce some stable geometry first (Fuse) in such case and build on that:
Stable.png
Stable.png (11.03 KiB) Viewed 959 times
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Hack of the day: make links more robust for almost free

Post by cox »

Nice idea:D @DeepSOIC

The less probability of renaming an already existing face the better I guess.
Need help? Feel free to ask, but please read the guidelines first
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Hack of the day: make links more robust for almost free

Post by ian.rees »

FWIW, I agree with Triplus. That's a clever workaround, but I'd be a bit leery of implementing too many of those instead of fixing the underlying topology problem. -Ian-
Post Reply