I was wondering if there was a function that would remove lines that are inside a sketch. I am not looking for isInside() because the lines in question are part of the sketch. In other words, I need an automatic way of getting lines that form the outline of the sketch.
Example:
Here is the starting sketch
1.
The function would return the internal lines of the sketch or simply delete them.
2.
This would be the result.
3.
Is there an existing function or algorithm to do this?
My FreeCAD Info:
OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Remove Internal Lines from Sketch
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Remove Internal Lines from Sketch
Moved from Developers forum. You post there if you are yourself a developer.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Remove Internal Lines from Sketch
Presuming the sketch contains multiple closed wires you could make each wire into its own face, then fuse the list of faces together, then refine the output (to remove extraneous edges), and take the OuterWire of the final face.
Select the sketch and press Ctrl+Shift+P. This opens the python console with a few variables created. shp is the shape of the sketch object.
Select the sketch and press Ctrl+Shift+P. This opens the python console with a few variables created. shp is the shape of the sketch object.
Code: Select all
#get the wires
wires = shp.Wires
#make the faces
faces = [Part.makeFace(w, "Part::FaceMakerCheese") for w in wires]
#fuse the faces
fusion = faces[0].fuse(faces[1:]) #fuses the first face to the remaining faces in the list
#note: above will fail if there is only one face, in which case just use faces[0] as the final_face below
#refine fusion object to remove extra edges
refined = fusion.removeSplitter()
final_face = refined.Face1
outer_wire = final_face.OuterWire
Part.show(outer_wire,"outer_wire")