Draft API/fr: Difference between revisions

From FreeCAD Documentation
(fin de traduction)
(Updating to match new version of source page)
Line 1: Line 1:
These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported.
=Draft_API/fr=


Example:
Ces fonctions font partie du '''Draft module''', et, une fois que le '''Draft module''' a été importé, elles peuvent être utilisées, dans les scripts, les macros, ou dans l'interpréteur '''Python'''.
<syntaxhighlight>

Exemple:
import FreeCAD
import FreeCAD
from Draft import *
from Draft import *
Line 9: Line 8:
mydistance = FreeCAD.Vector(2,2,0)
mydistance = FreeCAD.Vector(2,2,0)
move(myrect,mydistance)
move(myrect,mydistance)
</syntaxhighlight>




{{APIFunction|cut|FreeCAD.Object, FreeCAD.Object|Renvoie un objet construit, à partir de la différence de la coupe des 2 objets sélectionnés. Les objets originaux obtenu sont cachés.|Un nouvel objet est créé}}
{{APIFunction|cut|FreeCAD.Object, FreeCAD.Object|Returns a cut object made from the difference of the 2 given objects. The original objects get hidden.|The newly created object}}
{{APIFunction|extrude|FreeCAD.Object, Vector|Extrudes the given object in the direction given by the vector. The original object gets hidden.|The newly created object}}

{{APIFunction|formatObject|FreeCAD.Object, [FreeCAD.Object]|This function applies to the given target object the current properties set on the Draft toolbar (line color and line width), or copies the properties of a second object if provided. It also places the object in construction group if the construction button is pressed.|Nothing}}
{{APIFunction|extrude|FreeCAD.Object, Vector|Extrude l'objet sélectionné dans la direction donnée par le vecteur. L'objet d'origine est caché.|Un nouvel objet est créé}}
{{APIFunction|fuse|FreeCAD.Object, FreeCAD.Object|Returns an object made from the union of the 2 given objects. If the objects are coplanar, a special Draft Wire is used, otherwise the final object is a standard Part fuse.|The newly created object}}

{{APIFunction|getDraftPath|[string]|Returns the user or system path where the Draft module is running from. If a subpath or a filename is supplied, the full path to the subpath inside the Draft module is returned.|A file path}}
{{APIFunction|formatObject|FreeCAD.Object, [FreeCAD.Object]|Cette fonction s'applique à l'objet cible, compte tenu des propriétés actuelles, fixées sur la barre d'outils Draft (couleur et largeur de la ligne), ou, le cas échéant copie les propriétés d'un deuxième objet. Il met également l'objet dans le groupe de construction si le bouton de construction est pressé.|Aucun}}
{{APIFunction|getGroupContents|list|Scans recursively the given list for groups. If groups are encountered, their contents are appended to the list.|A list of FreeCAD Objects}}

{{APIFunction|getRealName|string|Strips the trailing numbers from an object name.|The stripped object name}}
{{APIFunction|fuse|FreeCAD.Object, FreeCAD.Object|Retourne un objet fabriqué à partir de la fusion des 2 objets sélectionnés. Si les objets sont coplanaires, un '''Draft Wire''' spécial est utilisé, sinon l'objet final est une fusion standard (standard Part fuse).|Un nouvel objet est créé}}
{{APIFunction|getSelection| |Returns the current FreeCAD selection.|The current FreeCAD selection.}}

{{APIFunction|makeCircle|radius, [placement], [facemode], [startangle], [endangle]|Creates a circle object with given radius. If a placement is given, it is used. If facemode is False, the circle is shown as a wireframe, otherwise as a face. If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.|The newly created object.}}
{{APIFunction|getDraftPath|[string]|Retourne le chemin d'accès utilisateur, ou système, à partir duquel, le Draft module est exécuté. Si un sous-dossier ou un nom de fichier est fourni, le chemin complet vers le sous-dossier de l'intérieur du Draft module est renvoyé.|Le chemin du fichier}}
{{APIFunction|makeDimension|Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector]|Creates a Dimension object measuring distance between first and second vectors, with the dimension line passign through the third vector if provided. The current line width and color from the Draft toolbar will be used. Instead of 2 vectors, you can also pass a FreeCAD object, and two integers (and optionally a vector where the dimension line must pass). In that case, the dimension will be associated with the object, and measure two of its vertices, indicated by the two given indice numbers.|The newly created object.}}

{{APIFunction|makeLine|Vector, Vector|Creates a line between the two given vectors. The current line width and color from the Draft toolbar will be used.|The newly created object.}}
{{APIFunction|getGroupContents|list|Scanne récursivement la liste de données pour les groupes. Si les groupes sont trouvés, leur contenu est ajouté à la liste.|Une liste d'Objets FreeCAD}}
{{APIFunction|makeRectangle|length, width, [placement], [facemode]|Creates a Rectangle object with length in X direction and height in Y direction. If a placement is given, it is used. If facemode is False, the rectangle is shown as a wireframe, otherwise as a face. The current line width and color from the Draft toolbar will be used.|The newly created object.}}

{{APIFunction|makeText|string or list, [Vector], [screenmode])|Creates a Text object, at the given point if a vector is provided, containing the string or the strings given in the list, one string by line. The current color from the Draft toolbar and the text height and font specified in preferences are used. If screenmode is True, the text always faces the view direction, otherwise it lies on the XY plane.|The newly created object.}}
{{APIFunction|getRealName|string|Sépare le numéro du nom de l'objet.|Le nom dépouillé de l'objet}}
{{APIFunction|makeWire|list or Part.Wire, [closed], [placement], [facemode]|Creates a DWire object from the given list of vectors or from the given Wire. If closed is True or if first and last points are identical, the wire is closed. If facemode is True (and wire is closed), the wire will appear filled. The current line width and color from the Draft toolbar will be used.|A new Draft DWire (not a Part Wire).}}

{{APIFunction|move|FreeCAD.Object or list, Vector, [copymode])|Moves the given object or the objects contained in the given list in the direction and distance indicated by the given vector. If copymode is True, the actual objects are not moved, but copies are created instead.|The object(s) (or their copies if copymode was True).}}
{{APIFunction|getSelection| |Retourne la sélection actuelle FreeCAD.|Retourne la sélection actuelle FreeCAD.}}
{{APIFunction|precision| |Returns the precision value from Draft user settings.|An integer.}}

{{APIFunction|rotate|FreeCAD.Object or list, angle, [center], [axis] ,[copymode]|Rotates the given object or the objects contained in the given list with the given angle around the given center if provided, using axis as a rotation axis. If axis is omitted, the rotation will be around the vertical Z axis. If copymode is True, the actual objects are not moved, but copies are created instead.|The objects (or their copies).}}
{{APIFunction|makeCircle|radius, [placement], [facemode], [startangle], [endangle]|Crée un objet cercle de rayon donné. Si une coordonnée est fournie, elle est utilisée. Si '''facemode est False''', le cercle est représenté comme un fil de fer (filaire), sinon, comme une face. Si '''startAngle''' et '''endAngle''' (en degrés) sont donnés, ils sont utilisés et l'objet apparaîtra comme un arc.|Un nouvel objet est créé.}}
{{APIFunction|scale|FreeCAD.Object or list, vector, [center], [copymode]|Scales the given object or the objects contained in the given list with a scale factors defined by the given vector (in X, Y and Z directions) around the given center if provided. If copymode is True, the actual objects are not moved, but copies are created instead.|The objects (or their copies).}}

{{APIFunction|select|FreeCAD.Object|Deselects everything and selects only the passed object|Nothing.}}
{{APIFunction|makeDimension|Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector]|Crée un objet '''Cotation''', mesure la distance entre le premier et le deuxième vecteur, avec la dimension de la ligne passant par le troisième vecteur, s'il est fourni. La largeur de ligne et la couleur affichée sur de la barre d'outils du projet seront utilisés. Au lieu de 2 vecteurs, vous pouvez également créer un objet FreeCAD de deux entiers (et éventuellement un vecteur) où la ligne de cotation doit passer. Dans ce cas, la dimension sera '''associée''' à l'objet, et la mesure des deux sommets, indiquée par les deux chiffres à l'indice donné.|Un nouvel objet est créé.}}
{{APIFunction|shapify|FreeCAD.Object|Transforms a parametric shape object into non-parametric.|The new object.}}

{{APIFunction|draftify|FreeCAD.Object or list|Turns the given object or each object of the given list into Draft parametric wires.|Nothing.}}
{{APIFunction|makeLine|Vector, Vector|Crée une ligne entre les deux vecteurs donnés. La largeur de ligne, et, la couleur courante sélectionnés dans la barre d'outils Draft seront utilisés.|Un nouvel objet est créé.}}
{{APIFunction|getSVG|FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)]|Creates a SVG representation of the given object. The linemodifier attribute is a scale factor (in percents) for line width, and textmodifier for text size. You can also optionally provide a tuple of vectors to define a projection plane, otherwise the geometry will be projected on the XY plane.|a string containing a SVG representation of the given object.}}

{{APIFunction|makeRectangle|length, width, [placement], [facemode]|Crée un objet Rectangle avec une longueur dans la direction X et la hauteur dans la direction Y. Si une position est donnée, elle est utilisée. Si '''facemode est False''', le rectangle est représenté comme un fil de fer (filaire), sinon, comme une face. La largeur de ligne et la couleur courante sélectionnés dans la barre d'outils Draft seront utilisés.|Un nouvel objet est créé.}}

{{APIFunction|makeText|string or list, [Vector], [screenmode])|Crée un '''objet Texte''', au point donné, contenant la chaîne ou les chaînes figurant dans la liste, une chaîne par ligne. La couleur actuelle de la barre d'outils Projet la hauteur du texte et la police spécifiée dans les préférences sont utilisés. Si '''screenmode est sur True''', le texte fait toujours face à la direction de la vue, sinon il se trouve sur le plan '''X, Y'''.|Un nouvel objet est créé.}}

{{APIFunction|makeWire|list or Part.Wire, [closed], [placement], [facemode]|Crée un objet (wire) dans la liste de données des vecteurs ou du fil donné. Si c'est un objet fermé (True), ou, si le premier et le dernier point sont identique, le fil est fermé. Si '''facemode est (True)''' (le fil est fermé), le fil, apparaîtra rempli. La largeur de ligne et la couleur courante sélectionnés dans la barre d'outils seront utilisés.|Un nouvel objet est créé.}}

{{APIFunction|move|FreeCAD.Object or list, Vector, [copymode])|Déplace l'objet ou les objets sélectionnés contenus dans la liste donnée ,dans la direction et la distance indiquée par le vecteur. Si '''CopyMode''' est sur True les objets réels ne sont pas déplacés, mais copiés à sa (leur) place.|L'objet ou les objets (ou leurs copies, si '''CopyMode''' était sur True).}}

{{APIFunction|precision| |Retourne la valeur de précision définie dans les paramètres utilisateur.|Un integer.}}

{{APIFunction|rotate|FreeCAD.Object or list, angle, [center], [axis] ,[copymode]|Tourne l'objet donné ou les objets sélectionnés à l'angle donné et autour du centre donnée s'ils sont fourni, en utilisant l'axe comme un axe de rotation. Si l'axe est omis, la rotation se fera autour de l'axe vertical '''Z'''. Si '''CopyMode''' est sur True, les objets réels ne sont pas déplacés, mais les copies sont créées à leur place.|Les objets (ou leurs copies).}}

{{APIFunction|scale|FreeCAD.Object or list, vector, [center], [copymode]|Redimensionne l'objet donné ou les objets sélectionnés au facteur d'échelle définis par le vecteur de donnés '''(X, Y et Z)''' autour du centre donné s'il est fourni. Si '''CopyMode''' est sur True les objets réels ne sont pas déplacés, mais les copies sont créées à la place.|Les objets (ou leurs copies).}}

{{APIFunction|select|FreeCAD.Object| Désélectionne tout, et, sélectionne uniquement l'objet survolé|Aucune.}}

{{APIFunction|shapify|FreeCAD.Object|Transforme un objet de forme '''paramétrique''' en objet '''non-paramétrique'''.|Un nouvel objet est créé.}}

{{APIFunction|draftify|FreeCAD.Object or list|Met l'objet, ou, chaque objet sélectionné(s) en fils paramétriques Projet.|Aucune.}}

{{APIFunction|getSVG|FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)]|Crée une représentation SVG de l'objet donné. L'attribut '''linemodifier''' est le facteur d'échelle (en pourcent) pour la largeur de la ligne, et '''textmodifier''' pour la taille du texte. Vous pouvez également éventuellement fournir un tuple de vecteurs pour définir un plan de projection, sinon la forme géométrique sera projetée sur le plan '''X, Y'''.|Une chaîne contenant la représentation SVG de l'objet sélectionné.}}




[[Category:API/fr]]


[[Category:API]]
{{languages/fr | {{en|Draft API}} {{es|Draft API/es}} {{it|Draft API/it}} {{ru|Draft API/ru}} {{se|Draft API/se}} }}
[[Category:Poweruser Documentation]]


{{clear}}
[[Category:Poweruser Documentation/fr]]
<languages/>

Revision as of 21:39, 5 December 2014

These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported.

Example:

 import FreeCAD
 from Draft import *
 myrect = makeRectangle(4,3)
 mydistance = FreeCAD.Vector(2,2,0)
 move(myrect,mydistance)


cut(FreeCAD.Object, FreeCAD.Object)

Description: Returns a cut object made from the difference of the 2 given objects. The original objects get hidden.

Returns: The newly created object

extrude(FreeCAD.Object, Vector)

Description: Extrudes the given object in the direction given by the vector. The original object gets hidden.

Returns: The newly created object

formatObject(FreeCAD.Object, [FreeCAD.Object])

Description: This function applies to the given target object the current properties set on the Draft toolbar (line color and line width), or copies the properties of a second object if provided. It also places the object in construction group if the construction button is pressed.

Returns: Nothing

fuse(FreeCAD.Object, FreeCAD.Object)

Description: Returns an object made from the union of the 2 given objects. If the objects are coplanar, a special Draft Wire is used, otherwise the final object is a standard Part fuse.

Returns: The newly created object

getDraftPath([string])

Description: Returns the user or system path where the Draft module is running from. If a subpath or a filename is supplied, the full path to the subpath inside the Draft module is returned.

Returns: A file path

getGroupContents(list)

Description: Scans recursively the given list for groups. If groups are encountered, their contents are appended to the list.

Returns: A list of FreeCAD Objects

getRealName(string)

Description: Strips the trailing numbers from an object name.

Returns: The stripped object name

getSelection( )

Description: Returns the current FreeCAD selection.

Returns: The current FreeCAD selection.

makeCircle(radius, [placement], [facemode], [startangle], [endangle])

Description: Creates a circle object with given radius. If a placement is given, it is used. If facemode is False, the circle is shown as a wireframe, otherwise as a face. If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.

Returns: The newly created object.

makeDimension(Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector])

Description: Creates a Dimension object measuring distance between first and second vectors, with the dimension line passign through the third vector if provided. The current line width and color from the Draft toolbar will be used. Instead of 2 vectors, you can also pass a FreeCAD object, and two integers (and optionally a vector where the dimension line must pass). In that case, the dimension will be associated with the object, and measure two of its vertices, indicated by the two given indice numbers.

Returns: The newly created object.

makeLine(Vector, Vector)

Description: Creates a line between the two given vectors. The current line width and color from the Draft toolbar will be used.

Returns: The newly created object.

makeRectangle(length, width, [placement], [facemode])

Description: Creates a Rectangle object with length in X direction and height in Y direction. If a placement is given, it is used. If facemode is False, the rectangle is shown as a wireframe, otherwise as a face. The current line width and color from the Draft toolbar will be used.

Returns: The newly created object.

makeText(string or list, [Vector], [screenmode]))

Description: Creates a Text object, at the given point if a vector is provided, containing the string or the strings given in the list, one string by line. The current color from the Draft toolbar and the text height and font specified in preferences are used. If screenmode is True, the text always faces the view direction, otherwise it lies on the XY plane.

Returns: The newly created object.

makeWire(list or Part.Wire, [closed], [placement], [facemode])

Description: Creates a DWire object from the given list of vectors or from the given Wire. If closed is True or if first and last points are identical, the wire is closed. If facemode is True (and wire is closed), the wire will appear filled. The current line width and color from the Draft toolbar will be used.

Returns: A new Draft DWire (not a Part Wire).

move(FreeCAD.Object or list, Vector, [copymode]))

Description: Moves the given object or the objects contained in the given list in the direction and distance indicated by the given vector. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The object(s) (or their copies if copymode was True).

precision( )

Description: Returns the precision value from Draft user settings.

Returns: An integer.

rotate(FreeCAD.Object or list, angle, [center], [axis] ,[copymode])

Description: Rotates the given object or the objects contained in the given list with the given angle around the given center if provided, using axis as a rotation axis. If axis is omitted, the rotation will be around the vertical Z axis. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The objects (or their copies).

scale(FreeCAD.Object or list, vector, [center], [copymode])

Description: Scales the given object or the objects contained in the given list with a scale factors defined by the given vector (in X, Y and Z directions) around the given center if provided. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The objects (or their copies).

select(FreeCAD.Object)

Description: Deselects everything and selects only the passed object

Returns: Nothing.

shapify(FreeCAD.Object)

Description: Transforms a parametric shape object into non-parametric.

Returns: The new object.

draftify(FreeCAD.Object or list)

Description: Turns the given object or each object of the given list into Draft parametric wires.

Returns: Nothing.

getSVG(FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)])

Description: Creates a SVG representation of the given object. The linemodifier attribute is a scale factor (in percents) for line width, and textmodifier for text size. You can also optionally provide a tuple of vectors to define a projection plane, otherwise the geometry will be projected on the XY plane.

Returns: a string containing a SVG representation of the given object.