Page 8 of 12
Re: Feature: offset tool in sketcher
Posted: Mon Feb 22, 2021 8:04 am
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
Re: Feature: offset tool in sketcher
Posted: Mon Feb 22, 2021 9:16 am
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
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 4:15 pm
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.
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 5:26 pm
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.
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 6:28 pm
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
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 6:30 pm
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.
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 6:33 pm
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?
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 6:37 pm
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
I guess there's first time for everything. I will give it a go.
Re: Feature: offset tool in sketcher
Posted: Sat Mar 13, 2021 6:48 pm
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
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.
Re: Feature: offset tool in sketcher
Posted: Sun Mar 14, 2021 4:51 pm
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