SVG to sketch?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
robofly
Posts: 10
Joined: Fri Jul 15, 2016 1:13 pm

SVG to sketch?

Post by robofly »

Hi,
I'm modeling an RC plane fuselage. I'd like to blend airfoil shape into the fuselage. The airfoil is an SVG image. I already succeeded doing this by subtracting shapes with boolean operation, but I'd like to know if it's possible to transfer vertices from SVG into a sketch, so I could have more control?
Files attached.

What I'm trying to achieve
body-with-airfoil-shape.png
body-with-airfoil-shape.png (59.27 KiB) Viewed 3306 times
OS: Linux Mint 18.1 Serena
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6707 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 5465bc47c95db45e0be85dc0e2872419efadce0f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
body-middle.fcstd
(11.8 KiB) Downloaded 116 times
chrisb
Veteran
Posts: 54168
Joined: Tue Mar 17, 2015 9:14 am

Re: SVG to sketch?

Post by chrisb »

In Draft Workbench you have Menu->Draft->Draft to Sketch. However this cannot deal yet with Sketcher's new B-Splines. I have written a macro which approximates the splines with circular arcs: https://forum.freecadweb.org/viewtopic. ... 71#p162571
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: SVG to sketch?

Post by microelly2 »

This creates some outer curves
p=App.ActiveDocument.path10

pts=[v.Point for v in p.Shape.Vertexes]
w=Draft.makeWire(pts)
Draft.makeSketch(w,autoconstraints=True)

bc=Part.BSplineCurve()
bc.interpolate(pts)
pk=App.ActiveDocument.addObject("Part::Spline","path10spline")
pk.Shape=bc.toShape()
The path10spline object you can convert to a sketcher bspline with this script:
https://github.com/microelly2/freecad-n ... hspline.py

It's still not optimized but it is a sketch ;)
Attachments
bp_421.png
bp_421.png (67.39 KiB) Viewed 3295 times
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: SVG to sketch?

Post by NormandC »

microelly2 wrote:The path10spline object you can convert to a sketcher bspline with this script


robofly wrote:Version: 0.16.6707 (Git)
^^^^^^^^^^^^^^^^^^^^
robofly
Posts: 10
Joined: Fri Jul 15, 2016 1:13 pm

Re: SVG to sketch?

Post by robofly »

Thanks a lot microelly2, I got it working (had to install some python dependencies first)!

I have another question. The script creates a new sketch from SVG, is it possible to copy/paste objects from one sketch to another?
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: SVG to sketch?

Post by NormandC »

robofly wrote:Thanks a lot microelly2, I got it working
How? BSplines are not available in 0.16.6707 which is the version you're using, they're being developed in 0.17 which is nowhere near ready to be released.

That was the point I was trying to make to microelly2 in my previous reply: he should have mentioned it...
robofly wrote:is it possible to copy/paste objects from one sketch to another?
It's not. But you can merge sketches into a single one, then you can delete the geometry you don't want. The Merge sketches utility is in the Part Design or Sketch menu.
robofly
Posts: 10
Joined: Fri Jul 15, 2016 1:13 pm

Re: SVG to sketch?

Post by robofly »

NormandC wrote: How? BSplines are not available in 0.16.6707 which is the version you're using, they're being developed in 0.17 which is nowhere near ready to be released.
I'm not exactly sure how :oops: Being a cad n00b I did a lot of clicking and lost track, but I have a sketch generated from SVG.
Take a look at the file, maybe you can figure it out. And thanks for the merging tip.
Attachments
body-middle.fcstd
(30.66 KiB) Downloaded 109 times
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: SVG to sketch?

Post by NormandC »

Your last sketch does not contain curves, but small straight lines.
chrisb
Veteran
Posts: 54168
Joined: Tue Mar 17, 2015 9:14 am

Re: SVG to sketch?

Post by chrisb »

The Macro I gave needs 0.17 as well (sorry, I forgot because I developed it some time ago), due to the fact that it uses stuff from the Path Workbench. However it might well work with 0.16 too if you integrate parts of Path Workbench's python code in PathUtils.py.
I'm not going to do it myself, because I guess that the conversion to Sketcher splines will come in the near future. The use of (circular) arcs only is still sensible if it comes to the generation of GCode for mill and lathe driving.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply