Feature: offset tool in sketcher

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
galou_breizh
Posts: 353
Joined: Wed Sep 15, 2010 9:38 am

Re: Feature: offset tool in sketcher

Postby galou_breizh » Mon Feb 22, 2021 8:04 am

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: 353
Joined: Wed Sep 15, 2010 9:38 am

Re: Feature: offset tool in sketcher

Postby galou_breizh » Mon Feb 22, 2021 9:16 am

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: 28
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Postby Petrikas » Sat Mar 13, 2021 4:15 pm

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.
chrisb
Posts: 33587
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Sat Mar 13, 2021 5:26 pm

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
Posts: 10244
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Postby Kunda1 » Sat Mar 13, 2021 6:28 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Petrikas
Posts: 28
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Postby Petrikas » 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.
User avatar
Kunda1
Posts: 10244
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Postby Kunda1 » Sat Mar 13, 2021 6:33 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Petrikas
Posts: 28
Joined: Sat Dec 05, 2020 8:05 pm

Re: Feature: offset tool in sketcher

Postby Petrikas » 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.
User avatar
Kunda1
Posts: 10244
Joined: Thu Jan 05, 2017 9:03 pm

Re: Feature: offset tool in sketcher

Postby Kunda1 » Sat Mar 13, 2021 6:48 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
edi
Posts: 270
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Sun Mar 14, 2021 4:51 pm

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