Yes, exactly. Rough is good.
I am sorry to be such a bother but... is there a way to import a ready outline into freeCad and make it part of the sketch?
Your'e after something like that? Attached the svg-path by hand roughly made from the picture.
Code: Select all
import numpy as np
#after pip install potracer
import potrace
from PIL import Image
#via https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Topological_data_scripting.md
def makeBCurveEdge(Points):
geomCurve = Part.BezierCurve()
geomCurve.setPoles(Points)
edge = Part.Edge(geomCurve)
return(edge)
#inspired by https://github.com/tatarize/potrace-cli/blob/main/cli/backend_svg.py
# and https://github.com/tatarize/potrace/issues/5
#SVG attributes: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
img=Image.open("/home/matt/Downloads/DXFtests/fm7es4338mye.jpeg")
img = img.convert("1", dither=Image.NONE)
data=np.asarray(img)
bitmap=potrace.Bitmap(data)
path=bitmap.trace()
segments = []
for p in path:
current_pt = p.start_point
for aseg in p.segments:
if aseg.is_corner:
a = aseg.c
#segments.append(App.Vector(a.x, a.y, 0.0))
b = aseg.end_point
#segments.append(App.Vector(b.x, b.y, 0.0))
if current_pt != a:
segments.append(Part.makeLine(App.Vector(current_pt.x, current_pt.y, 0.0),App.Vector(a.x, a.y, 0.0)))
segments.append(Part.makeLine(App.Vector(a.x, a.y, 0.0),App.Vector(b.x, b.y, 0.0)))
current_pt = b
else:
a = aseg.c1
b = aseg.c2
c = aseg.end_point
pt1 = App.Vector(a.x, a.y, 0.0)
pt2 = App.Vector(b.x, b.y, 0.0)
pt3 = App.Vector(c.x, c.y, 0.0)
if current_pt != a:
segments.append(Part.makeLine(App.Vector(current_pt.x, current_pt.y, 0.0),App.Vector(a.x, a.y, 0.0)))
potrace_edge = makeBCurveEdge((pt1,pt2,pt3))
segments.append(potrace_edge)
current_pt = c
if current_pt != p.start_point :
segments.append(Part.makeLine(App.Vector(current_pt.x, current_pt.y, 0.0),App.Vector(p.start_point.x, p.start_point.y, 0.0)))
for s in segments:
Part.show(s)
!!!New file - Import -> dagger-axe.svg as geometry (and yes 96dpi). !!! Wow! That's a godsend!
I should just have asked people for a ready model!papyblaise wrote: ↑Mon Jun 05, 2023 11:53 am make a guard and sharpen it, and this weapon "Can kill"
The crude but straightforward method is to make a copy of the FCStd file (outside of FreeCAD!)
Thank you.