Dimensions and scaling from Inkscape through the svg file into FreeCAD

en/fr/de/it


svg dimensions vs Inkscape  and FreeCAD dimensions
fr/de/it

Importing svg files from Inkscape into FreeCAD is not straightforward as one would expect. After struggling with the conversion of path objects into ellipses, lines and circles, I found out that in the imported sketch there are no imported contraints: you can still stretch all the objects, a common point between two lines (e.g. two consequent segments of a rectangle) consists of two different superimposed points in the sketch. This is easy -even if boring- to overcome: it’s enough to impose all the constraints by hand. When it comes to the dimensions constraints, another surprise comes: the imported objects have all been  stretched with a horizontal scaling factor which is different from the vertical scaling factor.

For example the sketch resulting from the import of a 50mmx100mm rectangle from Inkscape is a rectangle rect375.3117mmx151.538mm: it has been inexplicably scaled by 1.506234 horizontally and by 1,51538 vertically. Searching on the internet didn’t find out anything explaining this behaviour.

I did some further investigations and I found out that two rectangle shapes, drawn inside Inkscape with the same dimensions set in the GUI, are stored in the svg files as two objects with different width and height attributes.rect1 rect2

Fortunately the variations in the svg attributes from Inkscape is negligible for my purpose and, in any case, the precision of the FreeCAD sketcher when creating constraints between different shapes is rougher than the imprecision in the Inkscape attribute values.

So, how to proceed: the svg objects as ellipse, rectangles, lines and circles are recognized by FreeCAD when importing an svg file. Each imported svg object is imported as a FreeCAD “draft” object which can be converted into a “sketch” object. The relative position of the “draft” or “sketch” object with respect to the other objects is kept from the Inkscape original drawing. To remain on the safe side, I add by hand all the constraints: merging the vertexes of adjacent lines in just one point, fixing a point as belonging to a curve, adding “tangent” costraint between a line and an ellipse and so on. I also read in and confirme as constraint all the dimensions: line lengths, distance of any point from the x and the y axis to fix their absolute position in the sketch. With a fully constrained skectch then all the dimensions are fixed and there is no risk to stretch or move the objects by mistake.

There is still the need to revert back the introduced vertical and horizontal different scalings in the 2D objects, before extruding them with the original needed value in the third dimension. The trick is quite  simple: first I extrude the 2D wrongly stretched object, then with the “Draft” workbench I create  a clone which I can stretch back separately along the horizontal and the vertical dimensions to the original size.

Back to the top of page.


Le Titre
en/de/it
Cet est le text.
Retour en haut de page.


Der Titel
en/fr/it
Das ist das Text.
Zurück nach oben.

dimensioni svg vs dimensioni in Inkscape  e FreeCAD
en/fr/de

Importare file svg da Inkscape dentro FreeCAD non è così semplice come ci si aspetta. Dopo aver battagliato con la conversione di oggetti path in elissi, linee e cerchi, ho scoperto che nello sketch importato non ci sono contraints: si possono ridimensionare gli oggetti, un punto comune a due linee (per esempio due lati contingui di un rettangolo) consiste in due punti sovrapposti nello sketch. Questo è facile – anche se noioso – da risolvere: basta assegnare a mano tutti i constraints. Giunti ai constraints sulle dimensioni, c’è in serbo un’altra sorpresa: tutti gli oggetti importati sono stati ridimensionati con un fattore di scala orizzontale diverso da quello verticale. Per esempio,  importando da Inkscape un rettangolo di 50mm x 100mm nello sketch risulta un rettangolo di 75.3117mmx151.538mm: rect3è stato scalato inesplicabilmente di 1.506324 orizzontalmente e di 1.51538 verticalmente. Cercando su internet non ho trovato spiegazioni per questo comportamento. Investigando oltre, ho scoperto che disegnando due rettangoli con Inkscape e assegnando loro le stesse altezza e larghezza con l’interfaccia garfica, i due oggetti svg corrispondenti creati nel file xml  hanno valori diversi degli attributi width e height. rect2rect1

Dunque, come procedere: FreeCAD riconosce gli oggetti svg come ellipse, rectangle, line e circle quando si importa un file svg. Ciascun oggetto viene importato come oggetto draft in FreeCAD e lo si può convertire in un oggetto sketch. In entrambi gli oggetti viene mantenuta la posizione relativa di ciascun oggetto svg originale  rispetto agli altri del disegno di Inkscape. Per andare sul sicuro, aggiungo a mano tutti i constraint:  i vertici di due linee adiacenti si unificano in un punto solo, punti da fissare come appartenenti ad una curva, imporre che una linea si tangente all’ellisse a cui si raccorda, etc.  I also read in and confirmed as constraint all the dimensions: line lengths, distance of any point from the x and the y axis to fix their absolute position in the sketch. With a fully constrained skectch then all the dimensions are fixed and there is no risk to stretch or move the objects by mistake.

There is still the need to revert back the introduced vertical and horizontal different scalings in the 2D objects, before extruding them with the original needed value in the third dimension. The trick is quite  simple: first I extrude the 2D wrongly stretched object, then with the “Draft” workbench I create  a clone which I can stretch back separately along the horizontal and the vertical dimensions to the original size.

Ritorno all’inizio della pagina.

2 thoughts on “Dimensions and scaling from Inkscape through the svg file into FreeCAD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s