[Feature Request] Relative offset in Linear Pattern

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!
sugol
Posts: 5
Joined: Wed May 11, 2022 1:21 pm
Location: New Zealand

[Feature Request] Relative offset in Linear Pattern

Post by sugol »

Hi folks

This feature request has already been brought up here

I also wanted this functionality in FreeCAD, so I made a fork and implemented it.
Posting here as there doesn't seem to be a feature request on github, and it'd be good to have some dialog with the devs/community before I submit a PR

It functions basically as you would expect: when editing a linear pattern, you can switch between 'Length' and 'Offset' mode. 'Length' evenly distributes occurrences along a length (ie. the way that linear pattern currently works), while 'Offset' spaces each occurrence by some offset value. Screenies below if I'm unclear.
Length mode
Length mode
freecad2.png (52.37 KiB) Viewed 2044 times
Offset mode
Offset mode
freecad1.png (65.6 KiB) Viewed 2044 times
Currently we can use expressions to achieve this behaviour, but I think having it built into linear pattern is more intuitive.

Feedback and constructive criticism are very welcome!

- sugol
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: [Feature Request] Relative offset in Linear Pattern

Post by Jee-Bee »

This feature request is done more often i have done it my self. I have tried to figure out myself i was able to do it.
I was able find the feature back but at that moment i was unable to compile myself and the work looks a bit to complicated (for my level of c++ ;) )to just edit is and make a pull request.

If you interested just start looking here:
https://github.com/FreeCAD/FreeCAD/blob ... rPattern.h
https://github.com/FreeCAD/FreeCAD/blob ... attern.cpp

and

https://github.com/FreeCAD/FreeCAD/blob ... rameters.h
https://github.com/FreeCAD/FreeCAD/blob ... meters.cpp
https://github.com/FreeCAD/FreeCAD/blob ... ameters.ui
sugol
Posts: 5
Joined: Wed May 11, 2022 1:21 pm
Location: New Zealand

Re: [Feature Request] Relative offset in Linear Pattern

Post by sugol »

Jee-Bee wrote: If you interested just start looking here:
https://github.com/FreeCAD/FreeCAD/blob ... rPattern.h
https://github.com/FreeCAD/FreeCAD/blob ... attern.cpp

and

https://github.com/FreeCAD/FreeCAD/blob ... rameters.h
https://github.com/FreeCAD/FreeCAD/blob ... meters.cpp
https://github.com/FreeCAD/FreeCAD/blob ... ameters.ui
I've already gone through those files and made the relevant changes in my fork (linked in original post)
chrisb
Veteran
Posts: 54172
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature Request] Relative offset in Linear Pattern

Post by chrisb »

sugol wrote: Wed May 11, 2022 2:10 pm Feedback and constructive criticism are very welcome!
Looks like a good addition. Thanks for working on it!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
sugol
Posts: 5
Joined: Wed May 11, 2022 1:21 pm
Location: New Zealand

Re: [Feature Request] Relative offset in Linear Pattern

Post by sugol »

chrisb wrote:Looks like a good addition. Thanks for working on it!
No problem! I'll spend some more time getting the code cleaned up, and probably submit a PR when I have time in a couple of days
User avatar
adrianinsaval
Veteran
Posts: 5546
Joined: Thu Apr 05, 2018 5:15 pm

Re: [Feature Request] Relative offset in Linear Pattern

Post by adrianinsaval »

This would be a welcomed addition really, once you're happy with your implementation for linear pattern it would be nice to copy that for polar pattern too, considering that maybe there's a better word than offset that's applicable to angles too, separation? spacing?
I haven't looked at your code but consider using the same properties as before in the background or auto updating them to match so the pattern still works correctly if you open in an older version of FreeCAD, I know this isn't a priority but it would be nice and here it's possible to do it.
When you submit your PR keep in mind that we are currently in a feature freeze for 0.20 since it's close to release so this can only get merged once the 0.21 dev cycle starts.
sugol
Posts: 5
Joined: Wed May 11, 2022 1:21 pm
Location: New Zealand

Re: [Feature Request] Relative offset in Linear Pattern

Post by sugol »

adrianinsaval wrote:once you're happy with your implementation for linear pattern it would be nice to copy that for polar pattern too, considering that maybe there's a better word than offset that's applicable to angles too, separation? spacing?
I hadn't considered making this work with polar pattern too -- as you say we're in feature freeze for 0.20, so I'll probably spend some more time getting that working. 'Offset' was just the first thing that came to mind, separation/spacing is probably better terminology - maybe pitch?
adrianinsaval wrote:consider using the same properties as before in the background or auto updating them to match so the pattern still works correctly if you open in an older version of FreeCAD
The way I've implemented this actually makes pretty minimal changes to the existing code (for now :lol: ) so all the old properties are still used; I opened up a test part made with my fork in 0.19 and the part itself is the same. That being said I haven't yet implemented synchronisation between the length and offset values, so the UI in 0.19 doesn't match the actual dimensions of the part. But yes, proper backwards-compatibility should definitely be the goal here.
User avatar
adrianinsaval
Veteran
Posts: 5546
Joined: Thu Apr 05, 2018 5:15 pm

Re: [Feature Request] Relative offset in Linear Pattern

Post by adrianinsaval »

well I should have said if you recompute in an older version, when you just open it there won't be any difference because the shape isn't recomputed
User avatar
M4x
Veteran
Posts: 1480
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: [Feature Request] Relative offset in Linear Pattern

Post by M4x »

Are you aware of the Lattice2 workbench? Here is a basic tutorial describing the LinearArray feature: https://github.com/DeepSOIC/Lattice2/wi ... inearArray
User avatar
kadet
Posts: 102
Joined: Mon Aug 21, 2023 8:15 pm
Contact:

Re: [Feature Request] Relative offset in Linear Pattern

Post by kadet »

I've created PR for this request based on the work of @sugol (hope that that's okay with you!): https://github.com/FreeCAD/FreeCAD/pull/10377
Post Reply