Draft SVG: Difference between revisions
(note on the svg output precision of inkscpae) |
Renatorivo (talk | contribs) No edit summary |
||
(38 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
[[Image:Screenshot inkscape.jpg]] |
|||
<translate> |
|||
<!--T:16--> |
|||
{{docnav |
|||
|[[Draft_DXF|Autodesk .DXF .DWG]] |
|||
|[[Draft_OCA|Open Cad format .OCA]] |
|||
|[[Draft_Module|Draft Module]] |
|||
|IconC=Workbench_Draft.svg |
|||
}} |
|||
<!--T:1--> |
|||
===Opening=== |
|||
{{GuiCommand |
|||
|Name=Draft SVG |
|||
|MenuLocation=- |
|||
|Workbenches=[[Draft Workbench|Draft]] |
|||
|Shortcut=- |
|||
|SeeAlso=- |
|||
|Empty=1 |
|||
}} |
|||
==Description== <!--T:11--> |
|||
This function imports SVG files as workable 2D objects, in opposition to the built-in drawing module which imports svg files as sheet drawings. |
|||
The following SVG objects get imported at the moment: |
|||
<!--T:20--> |
|||
Draft SVG is a software module used by the [[File:Std_Open.svg|24px]] [[Std_Open|Std Open]], [[Std_Import|Std Import]] and [[Std_Export|Std Export]] commands to handle the [[SVG]] file format. |
|||
</translate> |
|||
[[Image:Screenshot inkscape.jpg]] |
|||
<translate> |
|||
<!--T:12--> |
|||
{{Caption|Inkscape drawing exported to SVG, which is subsequently opened in FreeCAD}} |
|||
==Importing== <!--T:2--> |
|||
<!--T:21--> |
|||
The following SVG objects can be imported: |
|||
* PATH objects |
* PATH objects |
||
* LINE objects |
* LINE objects |
||
Line 14: | Line 42: | ||
* POLYLINE objects |
* POLYLINE objects |
||
=== |
===Limitations=== <!--T:22--> |
||
<!--T:23--> |
|||
Works the same way as opening but creates the objects in the active document instead of creating a new one. |
|||
FreeCAD will not import path objects that have only one point ([https://forum.freecadweb.org/viewtopic.php?f=3&t=43856 forum discussion]). |
|||
==Exporting== <!--T:4--> |
|||
The following objects can be exported in an SVG file: |
|||
<!--T:24--> |
|||
The following FreeCAD objects can be exported: |
|||
* Lines and wires (polylines) |
* Lines and wires (polylines) |
||
* Arcs and circles |
* Arcs and circles |
||
Line 28: | Line 57: | ||
* Dimensions |
* Dimensions |
||
===Limitations=== <!--T:5--> |
|||
Keep in mind that SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened). |
|||
<!--T:25--> |
|||
===Preferences=== |
|||
SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened). |
|||
==Unit Handling== <!--T:7--> |
|||
The following parameters can be specified in the [[Draft Preferences]] tab (menu Edit -> Preferences -> Draft): |
|||
* Import/Export -> Import style: This lets you choose the way objects from the svg file will be drawn in FreeCAD. You can choose between: |
|||
** None: this is the faster way, there is no conversion, all objects will be black with 2px width (FreeCAD default) |
|||
** Use default color and linewidth: All imported objects will take current linewidth/color from the draft command bar |
|||
** Original color and linewidth: Objects will keep the color and linewidth (if specified) they have in the svg file |
|||
* Import/Export -> Export Style: |
|||
** Translated: All elements are translated that their coordinates are positive. This should aid display and printing. The output coordinate system is NOT cosistent between individualy exported elements. |
|||
** Raw: The position of all elements preserved. This intended for CAM usage for example in PyCAM. Layers or Slices exported individualy will match. |
|||
* General settings -> Internal precision level: |
|||
** This value is used to check if a bezier curve segement has to be considered a straight line. If you import detailed paths, like rendered text, you may want to increase this setting up to 6. If you are working with Inkscape please consider to raise the precision in the SVG file, well. (Inkscape Menu -> File -> Inkscape Preferences -> SVG Output -> Numeric Precision) |
|||
===Unit Handling=== |
|||
<!--T:26--> |
|||
When exporting, a User Unit (px) equals one millimeter. |
When exporting, a User Unit (px) equals one millimeter. |
||
<!--T:8--> |
|||
When importing, the width, height and viewBox attributes are respected. All elements are scaled to their size in millimeter, which is FreeCAD internal unit. If the SVG does not contain information on its physical size, it is assumed to have 90 DPI resolution. |
When importing, the width, height and viewBox attributes are respected. All elements are scaled to their size in millimeter, which is FreeCAD internal unit. If the SVG does not contain information on its physical size, it is assumed to have 90 DPI resolution. |
||
Using absoulte units in attributes inside the SVG should be avoided. Relative units like em,ex and % are currently not supported. |
Using absoulte units in attributes inside the SVG should be avoided. Relative units like em,ex and % are currently not supported. |
||
<!--T:9--> |
|||
The SVG Editor Inkscape currently works only with 90 DPI documents. No matter which unit is selected in Inkscape. All the output has to be considered converted to 90 DPI and '''rounded''' to 6 decimal places. As FreeCAD (and the SVG standard) is agnostic to the precision of rounding done in Inkscape these values will not be rounded on input. And odd values in millimeter will remain. |
|||
The [https://inkscape.org/ Inkscape] SVG Editor currently works only with 90 DPI documents. No matter which unit is selected in Inkscape. All the output has to be considered converted to 90 DPI and '''rounded''' to 6 decimal places. As FreeCAD (and the SVG standard) is agnostic to the precision of rounding done in Inkscape these values will not be rounded on input. And odd values in millimeter will remain. |
|||
If you need the SVG import not to be rounded, work on User Units (px) in Inkscape. Scaling can be done after the import to FreeCAD or by changing the width, height and viewbox attributes. |
If you need the SVG import not to be rounded, work on User Units (px) in Inkscape. Scaling can be done after the import to FreeCAD or by changing the width, height and viewbox attributes. |
||
==Preferences== <!--T:6--> |
|||
[[Category:User Documentation]] |
|||
<!--T:27--> |
|||
For more information see: [[Import_Export_Preferences|Import Export Preferences]]. |
|||
==Scripting== <!--T:13--> |
|||
<!--T:28--> |
|||
{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]]. |
|||
<!--T:14--> |
|||
You can export elements to SVG by using the following function: |
|||
</translate> |
|||
{{Code|code= |
|||
importSVG.export(exportList, filename) |
|||
}} |
|||
<translate> |
|||
<!--T:15--> |
|||
Example: |
|||
</translate> |
|||
{{Code|code= |
|||
import Draft, importSVG |
|||
Polygon1 = Draft.makePolygon(3, radius=500) |
|||
Polygon2 = Draft.makePolygon(5, radius=1500) |
|||
objects = [Polygon1, Polygon2] |
|||
importSVG.export(objects, "/home/user/Pictures/myfile.svg") |
|||
}} |
|||
<translate> |
|||
<!--T:10--> |
|||
{{docnav |
|||
|[[Draft_DXF|Autodesk .DXF .DWG]] |
|||
|[[Draft_OCA|Open Cad format .OCA]] |
|||
|[[Draft_Module|Draft Module]] |
|||
|IconC=Workbench_Draft.svg |
|||
}} |
|||
</translate> |
|||
{{languages | {{es|Draft SVG/es}} {{fr|Draft SVG/fr}} {{it|Draft SVG/it}} {{se|Draft SVG/se}} }} |
|||
{{Draft Tools navi{{#translation:}}}} |
|||
{{Userdocnavi{{#translation:}}}} |
|||
[[Category:Formats{{#translation:}}]] |
|||
[[Category:File Formats{{#translation:}}]] |
|||
{{clear}} |
Revision as of 21:11, 8 May 2020
Draft SVG |
Menu location |
---|
- |
Workbenches |
Draft |
Default shortcut |
- |
Introduced in version |
- |
See also |
- |
Description
Draft SVG is a software module used by the Std Open, Std Import and Std Export commands to handle the SVG file format.
Inkscape drawing exported to SVG, which is subsequently opened in FreeCAD
Importing
The following SVG objects can be imported:
- PATH objects
- LINE objects
- RECT objects
- CIRCLE objects
- ELLIPSE objects
- POLYGON objects
- POLYLINE objects
Limitations
FreeCAD will not import path objects that have only one point (forum discussion).
Exporting
The following FreeCAD objects can be exported:
- Lines and wires (polylines)
- Arcs and circles
- Faces
- Texts
- Dimensions
Limitations
SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened).
Unit Handling
When exporting, a User Unit (px) equals one millimeter.
When importing, the width, height and viewBox attributes are respected. All elements are scaled to their size in millimeter, which is FreeCAD internal unit. If the SVG does not contain information on its physical size, it is assumed to have 90 DPI resolution. Using absoulte units in attributes inside the SVG should be avoided. Relative units like em,ex and % are currently not supported.
The Inkscape SVG Editor currently works only with 90 DPI documents. No matter which unit is selected in Inkscape. All the output has to be considered converted to 90 DPI and rounded to 6 decimal places. As FreeCAD (and the SVG standard) is agnostic to the precision of rounding done in Inkscape these values will not be rounded on input. And odd values in millimeter will remain. If you need the SVG import not to be rounded, work on User Units (px) in Inkscape. Scaling can be done after the import to FreeCAD or by changing the width, height and viewbox attributes.
Preferences
For more information see: Import Export Preferences.
Scripting
See also: Draft API and FreeCAD Scripting Basics.
You can export elements to SVG by using the following function:
importSVG.export(exportList, filename)
Example:
import Draft, importSVG
Polygon1 = Draft.makePolygon(3, radius=500)
Polygon2 = Draft.makePolygon(5, radius=1500)
objects = [Polygon1, Polygon2]
importSVG.export(objects, "/home/user/Pictures/myfile.svg")
- Drafting: Line, Polyline, Fillet, Arc, Arc by 3 points, Circle, Ellipse, Rectangle, Polygon, B-spline, Cubic Bézier curve, Bézier curve, Point, Facebinder, ShapeString, Hatch
- Annotation: Text, Dimension, Label, Annotation styles, Annotation scale
- Modification: Move, Rotate, Scale, Mirror, Offset, Trimex, Stretch, Clone, Array, Polar array, Circular array, Path array, Path link array, Point array, Point link array, Edit, Subelement highlight, Join, Split, Upgrade, Downgrade, Wire to B-spline, Draft to sketch, Set slope, Flip dimension, Shape 2D view
- Draft Tray: Select plane, Set style, Toggle construction mode, AutoGroup
- Snapping: Snap lock, Snap endpoint, Snap midpoint, Snap center, Snap angle, Snap intersection, Snap perpendicular, Snap extension, Snap parallel, Snap special, Snap near, Snap ortho, Snap grid, Snap working plane, Snap dimensions, Toggle grid
- Miscellaneous: Apply current style, Layer, Manage layers, Add a new named group, Move to group, Select group, Add to construction group, Toggle normal/wireframe display, Create working plane proxy, Heal, Show snap toolbar
- Additional: Constraining, Pattern, Preferences, Import Export Preferences, DXF/DWG, SVG, OCA, DAT
- Context menu:
- Layer container: Merge layer duplicates, Add new layer
- Layer: Activate this layer, Select layer contents
- Text: Open hyperlinks
- Wire: Flatten
- Working plane proxy: Write camera position, Write objects state
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub