Feature: offset tool in sketcher

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Feature: offset tool in sketcher

Post by galou_breizh »

edi wrote: Wed Feb 03, 2021 8:50 am The original macro includes many "green" comments (# comment). But macros published in the master must have only "white" comments (''' comment''').
Lines starting with '#' are comments. They have the role of describing the code to the developer.
Strings following a line with "def ..." or "class ..." are DocStrings. They have the role of describing the function to the user, as they appear in the interpreter interface, e.g. with help(fun). Strings can be defined with ', ", ''', or """. The latest two are so called multi-line strings. Modules are also documented with DocStrings.

Gaël
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Feature: offset tool in sketcher

Post by galou_breizh »

About the redundant constraints: for offset lines, there is a point-symmetry constraint and a point-on-line constraint for the end of the helper line. This is redundant because the point-symmetry already brings the point of the helper line on the offset line.

Gaël
User avatar
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Post by Petrikas »

Awesome macro! I tested it out on FreeCAD 0.19, and it worked perfectly. Thanks!

However, just a FYI, it doesn't work at all with FreeCAD Linkstage3, here's the error:

Code: Select all

18:07:12  Traceback (most recent call last):
  File "C:/Users/---/AppData/Roaming/FreeCAD/Macro/Offset.FCMacro", line 439, in <module>
    ex = OffsetDialog() 
  File "C:/Users/---/AppData/Roaming/FreeCAD/Macro/Offset.FCMacro", line 34, in __init__
    self.tracker = DraftTrackers.lineTracker(scolor=(1,1,1),swidth=3,dotted=True) 
<class 'NameError'>: name 'DraftTrackers' is not defined
I tried enabling / disabling Draft workbench to no avail. I wonder if there's a way around this? Thanks again.
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Post by chrisb »

Petrikas wrote: Sat Mar 13, 2021 4:15 pm I wonder if there's a way around this?
If it works in master, you should ask realthunder about that.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Post by Kunda1 »

Petrikas wrote: Sat Mar 13, 2021 4:15 pm However, just a FYI, it doesn't work at all with FreeCAD Linkstage3, here's the error:

Code: Select all

18:07:12  Traceback (most recent call last):
  File "C:/Users/---/AppData/Roaming/FreeCAD/Macro/Offset.FCMacro", line 439, in <module>
    ex = OffsetDialog() 
  File "C:/Users/---/AppData/Roaming/FreeCAD/Macro/Offset.FCMacro", line 34, in __init__
    self.tracker = DraftTrackers.lineTracker(scolor=(1,1,1),swidth=3,dotted=True) 
<class 'NameError'>: name 'DraftTrackers' is not defined
I tried enabling / disabling Draft workbench to no avail. I wonder if there's a way around this? Thanks again.
Looks like this may be missing python import of some sort. Draft workbench was re-structured by @vocx and @carlopav. That could be the issue here.

Edit: try adding

Code: Select all

    import draftguitools.gui_trackers as DraftTrackers
to the top of the macro

Edit2: lol, the solution was this: https://forum.freecadweb.org/viewtopic. ... 70#p487199
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Post by Petrikas »

Just to contribute, I found that adding a line

Code: Select all

if App.Version()[5].find('LinkStage3') == 0: import draftguitools.gui_trackers as DraftTrackers
accounts for LinkStage3 fork, so it works there as well, as LinkStage3 has neither 0.18 nor 0.19 in its version description, which fails to import the DraftTrackers.

Solved the problem for me.
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Post by Kunda1 »

Petrikas wrote: Sat Mar 13, 2021 6:30 pm Just to contribute, I found that adding a line

Code: Select all

if App.Version()[5].find('LinkStage3') == 0: import draftguitools.gui_trackers as DraftTrackers
accounts for LinkStage3 fork, so it works there as well, as LinkStage3 has neither 0.18 nor 0.19 in its version description, which fails to import the DraftTrackers.

Solved the problem for me.
Nice!
Would you like to make a PR to update that?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Post by Petrikas »

Kunda1 wrote: Sat Mar 13, 2021 6:33 pm Nice!
Would you like to make a PR to update that?
I have no idea how to do that :D I guess there's first time for everything. I will give it a go.
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Post by Kunda1 »

Petrikas wrote: Sat Mar 13, 2021 6:37 pm
Kunda1 wrote: Sat Mar 13, 2021 6:33 pm Nice!
Would you like to make a PR to update that?
I have no idea how to do that :D I guess there's first time for everything. I will give it a go.
Read Github
If you have issues, DM me and I'll help. ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

Petrikas wrote: Sat Mar 13, 2021 6:30 pm Just to contribute, I found that adding a line

Code: Select all

if App.Version()[5].find('LinkStage3') == 0: import draftguitools.gui_trackers as DraftTrackers
accounts for LinkStage3 fork, so it works there as well, as LinkStage3 has neither 0.18 nor 0.19 in its version description, which fails to import the DraftTrackers.

Solved the problem for me.
I will add the line and make a PR in the next days
Post Reply