Feature: offset tool in sketcher

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Fri Sep 04, 2020 4:16 am

Good point. This would fulfil another longterm requirement.
bleber
Posts: 31
Joined: Thu Jun 30, 2016 5:12 pm

Re: Feature: offset tool in sketcher

Postby bleber » Sat Sep 05, 2020 10:17 am

Thanks for the macro.

If Ican suggest something I like to see a option to make the offset lines conected with the same contraints from the original lines, and some system to make the offset parametric, for example with reference lines between original and offset.
Attachments
offset constraints.FCStd
(12.35 KiB) Downloaded 5 times
captura offset constraints.png
captura offset constraints.png (24.66 KiB) Viewed 475 times
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Sun Sep 06, 2020 8:16 am

@Rana and bleber: I have recorded this desire. I think it will be possible, because the offset lines are calculated.
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Mon Sep 14, 2020 9:18 am

Attached you will find the new version 2.0 of the script.

New benefits:
- The offset chain is constrained
- Reference geometry is included

Keeping the offset feature you can:
- drag the figure with the mouse
- modify measures or create new measures
The issue arises after calling the macro: the selection is lost. If I select the lines after opening the dialog, the dialog hides behind the main FreeCAD window (perhaps again a MacOS issue).
I did not work on the selection problem till now. So the workflow has to be:

- load the sript into the python console
- open a sketch and select a chain of lines and arcs
- start the script

Warning: Depending on the constraints in the source sketch, redundant constraints may occur. You have to delete them manually.

Please tell me problems, bugs, desires, comments ...
Attachments
OffsetInSketcher02.FCMacro
(12.78 KiB) Downloaded 12 times
User avatar
Pauvres_honteux
Posts: 344
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: Feature: offset tool in sketcher

Postby Pauvres_honteux » Mon Sep 14, 2020 12:00 pm

Tested your macro on:
OS: openSUSE Leap 15.1 (KDE//usr/share/xsessions/default)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.Unknown
Build type: Release
Python version: 3.6.5
Qt version: 5.9.7
Coin version: 4.0.0
OCC version: 7.4.0

... and got this:

Code: Select all

Report view:

13:40:48  Traceback (most recent call last):
13:40:48    File "/home/drega_soid/.FreeCAD/Macro/OffsetInSketcher02.FCMacro", line 119, in calculate
13:40:48      OffsetInSketcher.calculate(OffsetValue) # do the calculation
13:40:48    File "/home/drega_soid/.FreeCAD/Macro/OffsetInSketcher02.FCMacro", line 362, in calculate
13:40:48      SortedEdges = interlinkedEdges(linesAndArcs()) # list of interlinked lines and arcs S0-E0,S1-E1, ...
13:40:48    File "/home/drega_soid/.FreeCAD/Macro/OffsetInSketcher02.FCMacro", line 202, in interlinkedEdges
13:40:48      SortedEdges.append(UnsortedEdges.pop(0)) # first element in UnsortedEdges list
13:40:48  IndexError: pop from empty list


Python console:

Python 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> Gui.runCommand('Std_RecentMacros',0)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge1',3.58656,-0.00800119,10,False)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge2',10,-0.00800082,6.87427,False)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge3',8.30448,-0.00799899,-8.46927,False)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge4',10,-0.00799815,-15.5681,False)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge5',7.18999,-0.00799762,-20,False)
>>> # Gui.Selection.addSelection('Unnamed','Sketch001','ExternalEdge6',-15,-0.00799868,-11.0796,False)
>>> 
.
I made one sketch containing a rectangle with a radius "dent" in it, then I mad a new one on the same plane as the first one while projecting/linking lines and arcs from the first one. Then executed your "OffsetInSketcher02.FCMacro", then selected the top line and continued around in a clock-wise fashion, then clicked on OK, see picture.
.
Offset_versus_inner_radius_Macro_2.png
Offset_versus_inner_radius_Macro_2.png (159.08 KiB) Viewed 287 times
.
The purpose of this test was to see if it could handle a disappearing radius (which it must handle [if radius < = 0 then ....] ).
I also noticed it didn't ask for which side it should offset it to.
It would be nice with an arrow in the 3D-viewport to click on, for that purpose.
And on top of all: this is a must-have in FC-master!
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Mon Sep 14, 2020 12:30 pm

I'm not sure about the must have respecting radii<0, because I don't know what the outcome should be. So as a simple solution such request could be rejected.

The side of the offset is determined by the orientation of the first line (see post above), a negative offset switches sides.
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Mon Sep 14, 2020 1:33 pm

@Pauvres_honteux: thanks for testing, but sorry, the case you tested is not implemented yet.

Please respect the constraints (see post above):
- the selected lines may be an open or a closed line chain (see examples)
- the offset value may be a positive or a negative float value
- all selected lines must form one zigzag line (if not, only the first line will be taken)
- arcs are allowed, but must be tangential to their nearby objects (as if using the M-button in the CreatePolyline command)
The third constraint should be better:

- all selected lines must form one continous line (if not, only the lines connected to the first created line will be taken)

You can create your figure in the following way (but without having the full parametric):
- select all lines except the arc
- run the script
- select only the arc
- run the script
- connect the two offset figures manually (see attached example)
Attachments
OffsetExample.FCStd
example for Pauvres_honteux
(13.75 KiB) Downloaded 4 times
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Mon Sep 14, 2020 6:05 pm

This works very well now!

I have some suggestions concerning the constraints:

Instead of using orthogonal plus point-on-object you could use the variant orthogonal point-on-line

If such construction geometry is created manually it is usually placed at the end of one of the lines. You can then replace the point-on-object constraint by a coincidence.

If you really want to position the construction lines in the middle of the lines use a symmetry constraint. Please note that this implies the point-on-object constraint.

Let me know if you need an example of my suggestions.
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Mon Sep 14, 2020 10:40 pm

edi wrote:
Mon Sep 14, 2020 9:18 am
I did not work on the selection problem till now. So the workflow has to be:

- load the sript into the python console
You probably mean the Python editor. For me the workaround is
- start the macro; a dialog is opened
- select the geometric elements
- bring the dialog to front and start it.
User avatar
Pauvres_honteux
Posts: 344
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: Feature: offset tool in sketcher

Postby Pauvres_honteux » Tue Sep 15, 2020 1:20 pm

edi wrote:
Mon Sep 14, 2020 1:33 pm
@Pauvres_honteux: thanks for testing, but sorry, the case you tested is not implemented yet.
.
What I was phishing for was If you had it on your to-do-list. Since you typed "is not implemented yet" my lightbulb didn't go out anyway.
Jokes aside, the use case I showed is real and used alot in the industri by us pro's.
.
Of course I understand programing take its time, so to just have the feature request firmly on your radar is already a big step forward, in my opinion.
Last edited by Pauvres_honteux on Wed Sep 16, 2020 5:02 pm, edited 1 time in total.