Feature: offset tool in sketcher

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Feature: offset tool in sketcher

Postby edi » Tue Sep 01, 2020 6:25 am

Attached a script creatung offset lines in a sketch, see examples:
Offestexamples.png
Offestexamples.png (16.37 KiB) Viewed 749 times
Using the macro:

- select some lines and arcs in an active sketch
- start the macro
- enter the offset value

A line chain parallel to the selected lines and arcs is created

Benefits and restraints:

- 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)

If the offset value is positive, the elements are positioned on the right side of the original. (imagine the selected lines are a road, the right side is where cars drive in continental europe or the US. Driving direction is from startpoint to endpoint of the first selected edge)

Please give me further desires and comments.
Attachments
OffsetInSketcher.FCMacro
(6.63 KiB) Downloaded 31 times
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Tue Sep 01, 2020 7:06 am

Great macro, it had often been asked for!

Some remarks:
- doesn't work if just one line is selected
- It works with tangents to arcs even if they don't have a tangential constraint, they just have to be tangential by some other construction method.
- works with collinear lines as well; so no real zigzag is required, only a connection is needed
- constraints are missing. At least all connecting constraints could be added: coincidence, and point-to-point tangency and orthogonality.
- doesn't work on B-splines (which may not be worth the effort anyway).

If you can add the missing constraints I can very well imagine to have this integrated into Master.

P.S. I am eagerly waiting for TheMarkster's CallRecentMacros for testing such things.
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Tue Sep 01, 2020 7:19 am

I may add that some kind of continuation mode would be great: just select one edge and all subsequently connected lines are offset as well. By the way: trying that revealed the only-one-line-selected issue.
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Tue Sep 01, 2020 7:45 am

- doesn't work if just one line is selected
I cannot confirm this. With me the sript works with a single line or single arc selected. Please check once more. The script does not work with circles, but I can include this.
- It works with tangents to arcs even if they don't have a tangential constraint, they just have to be tangential by some other construction method.
- works with collinear lines as well; so no real zigzag is required, only a connection is needed
I confirm this. My description was not precise.
- constraints are missing. At least all connecting constraints could be added: coincidence, and point-to-point tangency and orthogonality.
I will realise this. I had this option in mind, but want to check wheater bugs are found before extending the script.
I may add that some kind of continuation mode would be great: just select one edge and all subsequently connected lines are offset as well.
I will keep this idea in mind.
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Tue Sep 01, 2020 8:20 am

edi wrote:
Tue Sep 01, 2020 7:45 am
Please check once more.
It seems to be a selection problem, perhaps only on the Mac. My workflow is:
- Select a line
- call the macro
- set the offset and confirm.

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).

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22284 (Git)
Build type: Release
Branch: master
Hash: bf1e8e48389f5e9e25bd77b67fe98da4213e797c
Python version: 3.8.5
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Tue Sep 01, 2020 8:42 am

Same behaviour on Ubuntu. You may have a look at Mario's FCCamera macro or ask him directly. That macro - and others from him - don't change the selection and don't fall behind the main window.


OS: Ubuntu 16.04.7 LTS (Unity/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 9beeb53a98a5f350ff185bfe0e339f38faa70512
Python version: 3.5.2
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
edi
Posts: 79
Joined: Fri Jan 17, 2020 1:32 pm

Re: Feature: offset tool in sketcher

Postby edi » Tue Sep 01, 2020 9:45 am

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 confirm this problem.

I found another problem: if the length of a line is less than the offset value a funny figure arises, because no correct solution is existing.
chrisb
Posts: 27297
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature: offset tool in sketcher

Postby chrisb » Tue Sep 01, 2020 11:31 am

We know something similar from science fiction movies where you pass some magic gate and find yourself in a completely different world with different laws of nature and probably different laws of mathematics. :)
User avatar
Gregory son of Carl
Posts: 99
Joined: Mon Apr 06, 2020 7:42 pm
Location: California

Re: Feature: offset tool in sketcher

Postby Gregory son of Carl » Tue Sep 01, 2020 11:05 pm

Thanks for making this macro. I'm excited to see the sketcher get an offset tool.
Rana
Posts: 16
Joined: Tue Oct 01, 2019 6:37 pm

Re: Feature: offset tool in sketcher

Postby Rana » Fri Sep 04, 2020 2:37 am

Thanks for the macro.
Is it possible to include reference geometry as active geometry with and without offset, as in many commercial softwares ?

Thanks.
rana