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!
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

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.
@chrisb:
I try to show you the problem in the attached picture. Imagine allways the left lines are original, the right are the offset lines. The offset value is positive.
Left subfigure: (offset line inside)
Everything OK. The distance line startpoint is at the endpoint of the first offset line.
Middle subfigure: (offset line outside)
The distance line startpoint is at the endpoint of the first offset line. Script fails, distance line endpoint cannot be connected to original line using PointOnObject.
Right subfigure:
The logic alternative: the distance line starts at the endpoint of the original line.

Distinguish between the left and the middle situation is complicated. The original line has been created by the user. It can be reversed, etc. It is difficult to determine on which side the offset line is situated, etc. The script is not "allowed" to change ist.
So I had the idea, to start the distance line at the midpoint of the offset line. The offset line has been created by the script. The script "knows" everything about it, and can create it as needed. The distance line (in normal situations) allways finds a counterpart for using PointOnObject.

Manually it is very easy to decide about starting at the original or the offset line, and to decide about taking the startpoint or the endpoint. The script needs an as possible simple algorithm which is working in every situation. Thats the problem.
OffsetSituation.png
OffsetSituation.png (5.83 KiB) Viewed 2411 times
Last edited by edi on Wed Sep 16, 2020 1:15 pm, edited 2 times in total.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Post by chrisb »

Aah, I see, and I agree that it can be complicated to determine the correct point for coincidence, And since it cannot be done systematically, i.e. either always connected to the original or always at the copy it is clearer to have these points in the middle. I will think about counterexamples using symmetry.

Edit: It may look cumbersome, but it is possible to have a point-on-object constraint that doesn't really lies on the line segment but rather on the (infinite) line going through it.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

If you really want to position the construction lines in the middle of the lines use a symmetry constraint.
Will be implemented.

I found a little bug: if the selected elements are all arcs (not any line), draging with the mouse leads to wrong figures. The problem can be solved manually be adding a Coincident constraint at the common center of one pair of concentric arcs.

Note: if you do this at a single arc, the sketcher is locked. No drag is possible although the sketch has 6 remaining degrees of freedom.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Post by chrisb »

edi wrote: Wed Sep 16, 2020 1:33 pm
I found a little bug:
I will look at this later. You may have a silently partially dropped constraint causing this behaviour.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Post by chrisb »

edi wrote: Wed Sep 16, 2020 1:33 pm
if the selected elements are all arcs (not any line), draging with the mouse leads to wrong figures. The problem can be solved manually be adding a Coincident constraint at the common center of one pair of concentric arcs.
I cannot confirm. I used the attached example and created an offset of 3. I then can perfectly move the arcs. Can you upload your example?

BTW: The offset input field doesn't seem to be unit aware.
Attachments
arcsOnly.FCStd
(4.53 KiB) Downloaded 56 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

Attached my example making problems. It's funny, your example arcsOnly.FCStd works without problems.
BTW: The offset input field doesn't seem to be unit aware.
I do not understand this. So far I only worked with [mm] as length units.

But looking ahead: I am working at version 3.0, defining the offset value analog, using a "rubber band" similar to the addCopy command. This will solve all the problems with lost selections, hidden input dialogs and the choice of the offset side.
Attachments
OffsetTest.FCStd
(6.16 KiB) Downloaded 65 times
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

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

New benefits:
- the offset distance is defined analog, using a "rubber band"
- appearance of the offset line (right/left) or (inside/outside) is also defined using the "rubber band"

The workflow is similar to other commands in the sketcher:

- select a chain of lines and arcs in an opened sketch
- show value of offset distance and appearance of offset lines using a "rubber band"

Please tell me found problems, bugs, desires, comments ...

One idea: the two closing lines at an open chain could be geometry lines, so that the resulting figure is closed and can be used immediately in the pad command etc.
Attachments
OffsetInSketcher03.FCMacro
(14.39 KiB) Downloaded 119 times
User avatar
Pauvres_honteux
Posts: 728
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: Feature: offset tool in sketcher

Post by Pauvres_honteux »

Seams as a module "DraftTrackers" is missing?
.

Code: Select all

Report view:

12:42:15  Traceback (most recent call last):
  File "/home/drega_sojd/.FreeCAD/Macro/OffsetInSketcher03.FCMacro", line 3, in <module>
    import DraftTrackers,re, math
<class 'ModuleNotFoundError'>: No module named 'DraftTrackers'

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.Selection.addSelection('Offset_versus_inner_radius','Sketch001')
>>> # Gui.Selection.clearSelection()
>>> ActiveSketch = App.getDocument('Offset_versus_inner_radius').getObject('Sketch001')
>>> tv = Show.TempoVis(App.ActiveDocument, tag= ActiveSketch.ViewObject.TypeId)
>>> ActiveSketch.ViewObject.TempoVis = tv
>>> if ActiveSketch.ViewObject.EditingWorkbench:
>>>   tv.activateWorkbench(ActiveSketch.ViewObject.EditingWorkbench)
>>> if ActiveSketch.ViewObject.HideDependent:
>>>   tv.hide(tv.get_all_dependent(App.getDocument('Offset_versus_inner_radius').getObject('Sketch001'), ''))
>>> if ActiveSketch.ViewObject.ShowSupport:
>>>   tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")])
>>> if ActiveSketch.ViewObject.ShowLinks:
>>>   tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])
>>> tv.hide(ActiveSketch)
>>> del(tv)
>>> 
>>> ActiveSketch = App.getDocument('Offset_versus_inner_radius').getObject('Sketch001')
>>> if ActiveSketch.ViewObject.RestoreCamera:
>>>   ActiveSketch.ViewObject.TempoVis.saveCamera()
>>> 
>>> # Gui.Selection.addSelection('Offset_versus_inner_radius','Sketch001','ExternalEdge3',-21.3357,-0.00800477,40,False)
>>> # Gui.Selection.addSelection('Offset_versus_inner_radius','Sketch001','ExternalEdge4',30,-0.00800168,14.0662,False)
>>> Gui.runCommand('Std_RecentMacros',0)
>>>
.
Offset_missing_module_DraftTrackers_macro_3.png
Offset_missing_module_DraftTrackers_macro_3.png (244.29 KiB) Viewed 2177 times
.
Same procedure as before, but this time I only selected the two green straight lines.
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Post by edi »

In Version 0.18 the module DraftTrackers is standard.

In Ubuntu you should have a file DraftTrackers.py in the .../freecad/Mod/Draft directory.

In Windows it is in the .../FreeCAD.018/Mod/Draft directory

Maybe you have not activated the Draft Workbench ?
User avatar
Pauvres_honteux
Posts: 728
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: Feature: offset tool in sketcher

Post by Pauvres_honteux »

edi wrote: Tue Sep 22, 2020 11:30 am In Version 0.18 the module DraftTrackers is standard.
Maybe you have not activated the Draft Workbench ?
.
Just tried with activated Draft Workbench, but no difference.
Post Reply