Draft SVG/ru: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
{{GuiCommand |
|||
|Name=Draft SVG |
|||
|MenuLocation=File → Export → Flattened SVG (*.svg) |
|||
|Workbenches=[[Draft Workbench|Draft]] |
|||
|Shortcut=Ctrl+E |
|||
|SeeAlso=[[Draft DXF]], [[FreeCAD and DXF Import]] |
|||
|Empty=1 |
|||
}} |
|||
== Description == |
|||
⚫ | |||
[[Image:Screenshot inkscape.jpg]] |
[[Image:Screenshot inkscape.jpg]] |
||
{{Caption|Inkscape drawing exported to SVG, which is subsequently opened in FreeCAD}} |
|||
== |
== Opening == |
||
⚫ | |||
The following SVG objects get imported at the moment: |
The following SVG objects get imported at the moment: |
||
* PATH objects |
* PATH objects |
||
Line 13: | Line 25: | ||
* POLYLINE objects |
* POLYLINE objects |
||
== |
== Importing == |
||
Works the same way as opening but creates the objects in the active document instead of creating a new one. |
Works the same way as opening but creates the objects in the active document instead of creating a new one. |
||
== |
== Exporting == |
||
The following objects can be exported in an SVG file: |
The following objects can be exported in an SVG file: |
||
* Lines and wires (polylines) |
* Lines and wires (polylines) |
||
Line 26: | Line 38: | ||
Keep in mind that SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened). |
Keep in mind that SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened). |
||
== |
== Preferences == |
||
The following parameters can be specified in the [[Draft Preferences]] tab ( |
The following parameters can be specified in the [[Draft Preferences]] tab ({{MenuCommand|Edit → Preferences → Draft}}): |
||
* Import/Export |
* 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) |
** 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 |
** 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 |
** Original color and linewidth: Objects will keep the color and linewidth (if specified) they have in the svg file |
||
* Import/Export |
* 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 |
** Translated: All elements are translated that their coordinates are positive. This should aid display and printing. The output coordinate system is not consistent between individually exported elements. |
||
** Raw: The position of all elements preserved. This intended for CAM usage for example in PyCAM. Layers or Slices exported |
** Raw: The position of all elements preserved. This intended for CAM usage for example in PyCAM. Layers or Slices exported individually will match. |
||
* General settings |
* General settings → Internal precision level: |
||
** This value is used to check if a bezier curve segment 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 |
** This value is used to check if a bezier curve segment 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 {{MenuCommand|Menu → File → Inkscape Preferences → SVG Output → Numeric Precision}}) |
||
== |
== Unit Handling == |
||
When exporting, a User Unit (px) equals one millimeter. |
When exporting, a User Unit (px) equals one millimeter. |
||
Line 47: | Line 59: | ||
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. |
||
== Scripting == |
|||
{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]]. |
|||
You can export elements to SVG by using the following function: |
|||
{{Code|code= |
|||
importSVG.export(exportList, filename) |
|||
}} |
|||
Example: |
|||
{{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") |
|||
}} |
|||
<div class="mw-translate-fuzzy"> |
|||
[[Category:User Documentation/ru]] |
[[Category:User Documentation/ru]] |
||
</div> |
|||
{{clear}} |
Revision as of 20:21, 23 January 2019
Draft SVG |
Menu location |
---|
File → Export → Flattened SVG (*.svg) |
Workbenches |
Draft |
Default shortcut |
Ctrl+E |
Introduced in version |
- |
See also |
Draft DXF, FreeCAD and DXF Import |
Description
This function imports SVG files as workable Draft Workbench objects, as opposed to the Drawing Workbench Open SVG function which imports SVG files as sheet drawings.
Inkscape drawing exported to SVG, which is subsequently opened in FreeCAD
Opening
The following SVG objects get imported at the moment:
- PATH objects
- LINE objects
- RECT objects
- CIRCLE objects
- ELLIPSE objects
- POLYGON objects
- POLYLINE objects
Importing
Works the same way as opening but creates the objects in the active document instead of creating a new one.
Exporting
The following objects can be exported in an SVG file:
- Lines and wires (polylines)
- Arcs and circles
- Faces
- Texts
- Dimensions
Keep in mind that SVG is a 2D format, so all Z information will be disregarded (all objects will be flattened).
Preferences
The following parameters can be specified in the Draft Preferences tab (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 consistent between individually exported elements.
- Raw: The position of all elements preserved. This intended for CAM usage for example in PyCAM. Layers or Slices exported individually will match.
- General settings → Internal precision level:
- This value is used to check if a bezier curve segment 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
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 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. 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.
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")