Feature: offset tool in sketcher
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Feature: offset tool in sketcher
Yes you did: you made me tackle the problem .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Feature: offset tool in sketcher
This macro is really great. I'm glad it's included in the Addon manager. But what about implementing this in FreeCAD so that it becomes a built-in functionality ?
edi wrote:edi
Are there any plans for that ? Was feature request created ?chrisb wrote:chrisb
Re: Feature: offset tool in sketcher
As far as I know has Abdullah this on his list. So it may come at some time in the future. Until then there is not too much disadvantage using the macro.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Feature: offset tool in sketcher
Great, thanks for letting me know.
Re: Feature: offset tool in sketcher
I made a small update to this so that you can select external geometry as well as normal geometry.
- Attachments
-
- offset.FCMacro
- (19.54 KiB) Downloaded 89 times
Re: Feature: offset tool in sketcher
I tried with this sketch, once selecting all, and once selecting only the outer cirumference. Nothing happens beyond the dotted line for selecting the offset. I have called the macro from Python console.
- Attachments
-
- SnipScreenshot-fc86a6.png (5.29 KiB) Viewed 2857 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Feature: offset tool in sketcher
Thanks for taking a look - Turns out I was using the linkstage3 branch and it has a Sketch.ExternalGeo list which i didn't realize was specific to that branch. I tried the macro in main branch of freecad v 0.2 and I've now updated the macro to use either Sketch.ExternalGeometry or Sketch.ExternalGeo so the macro should work in both the main branch and linkstage3 for external geometry.
- Attachments
-
- sketchflow_offset_v2.FCMacro
- (20.27 KiB) Downloaded 94 times
Re: Feature: offset tool in sketcher
This is with selecteing all external references. Solver message: "Solver failed to converge"
This is selecting only the outer circumference as shown in the screenshot starting at left vertical line and going clockwise:
- Attachments
-
- failedToConverge2.FCStd
- (5 KiB) Downloaded 60 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Feature: offset tool in sketcher
It is the toponaming problem.
-If Sketch is closed, it becomes a "shape". Each edge receives another number, see numbers in (). Left vertical = (1), arc = (3), bottom = (5)
The extern geometry in Sketch001 receives the numbers of the "shape". If the right vertical 3 is selected as external, the arc (3) is taken.
-Inside Sketch the edges are numbered as shown in the above picture. Left vertical = 1, arc = 2, bottom = 4, etc.-If Sketch is closed, it becomes a "shape". Each edge receives another number, see numbers in (). Left vertical = (1), arc = (3), bottom = (5)
The extern geometry in Sketch001 receives the numbers of the "shape". If the right vertical 3 is selected as external, the arc (3) is taken.
Re: Feature: offset tool in sketcher
A script which replaces "External geometry" of a sketch by regular lines:
Workflow:
- Create a first sketch, parallel to x/y plane, including several line segments or arcs of circles.
- Close the first sketch.
- Create a second sketch, parallel to x/y plane.
- Select several objects of the first sketch as "External geometry".
- Start the script.
Limitations:
- Both sketches must be parallel to x/y plane.
- Only line segments and arcs of circle can be replaced.
Usage: Replace External geometry by regular lines. Subsequent use them in the OffsetTool macro.
@ db2000: See how to connect external sketch geometry to internal sketch geometry avoiding the toponaming problem.
Code: Select all
'''
Replace all external geometry items by regular geometry items
'''
from FreeCAD import Base
externGeo = ActiveSketch.ExternalGeometry # get all external items in active sketch
externSketch = externGeo[0][0] # the extern sketch realy containing the items
externSelectedList = externGeo[0][1] # list containing external geometry objects as text strings
externEdgesList = externSketch.Shape.Edges # list containing external geometry objects as shape edges
newEdges = [] # empty list of new created items
for num,externSelected in enumerate(externSelectedList):
index = int(''.join(c for c in externSelected if c.isdigit())) # strip out the numeric index from the name
edge = externEdgesList[index-1] # one edge as shape item
if hasattr(edge.Curve,'Center'): # edge is an arc of circle
baseCircle = Part.Circle(edge.Curve.Center,Base.Vector(0,0,1),edge.Curve.Radius)
newEdges.append(Part.ArcOfCircle(baseCircle,edge.FirstParameter,edge.LastParameter))
else: # edge is a line segment
startPoint = edge.Vertexes[0].Point
endPoint = edge.Vertexes[1].Point
newEdges.append(Part.LineSegment(startPoint,endPoint))
ActiveSketch.addGeometry(newEdges,False) # add all created items to active sketch
for externSelected in externSelectedList: # remove all external geometry
ActiveSketch.delExternal(0)
App.ActiveDocument.recompute()
- Create a first sketch, parallel to x/y plane, including several line segments or arcs of circles.
- Close the first sketch.
- Create a second sketch, parallel to x/y plane.
- Select several objects of the first sketch as "External geometry".
- Start the script.
Limitations:
- Both sketches must be parallel to x/y plane.
- Only line segments and arcs of circle can be replaced.
Usage: Replace External geometry by regular lines. Subsequent use them in the OffsetTool macro.
@ db2000: See how to connect external sketch geometry to internal sketch geometry avoiding the toponaming problem.