Draft API/es: Difference between revisions

From FreeCAD Documentation
(languages/it)
(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.
Estas funciones son parte del módulo de Draft (Borrador) y pueden utilizarse en archivos de guión y macros o desde el interprete de Python, una vez se halla importado el módulo Draft.


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




{{APIFunction/es|cut|FreeCAD.Object, FreeCAD.Object|Devuelve un objeto cut creado a partir de la diferencia de 2 objetos dados. Los objetos originales se ocultan.|El nuevo objeto creado}}
{{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|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|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|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|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|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|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|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|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|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|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/es|extrude|FreeCAD.Object, Vector|Extruye el objeto dado en la dirección indicada por el vector. El objeto original se oculta.|El nuevo objeto creado}}


[[Category:API]]
{{APIFunction/es|formatObject|FreeCAD.Object, [FreeCAD.Object]|Esta función aplica al objeto de objetivo indicado las propiedades actuales establecidas en la barra del entorno Borrador (línea, color y ancho de línea), o copia las propiedades a un segundo objeto si se indica. También pone el objeto en el grupo "En construcción" si el botón "Construcción" está presionado.|Nada}}
[[Category:Poweruser Documentation]]


{{clear}}
{{APIFunction/es|fuse|FreeCAD.Object, FreeCAD.Object|Devuelve un objeto creado a partir de la unión de dos objetos dados. Si los objetos son coplanares, se utiliza una polilínea de borrador especial, en otro caso el objeto final es una fusión de piezas estándar.|El nuevo objeto creado}}
<languages/>

{{APIFunction/es|getDraftPath|[string]|Devuelve la ruta del usuario o sistema desde donde se está ejecutando el módulo Borrador. Si se suministra una sub-ruta o un nombre de archivo, devuelve la ruta completa a la sub-ruta dentro del módulo Borrador.|Una ruta de archivo}}

{{APIFunction/es|getGroupContents|list|Escanea recursivamente por la lista de grupos indicada. Si se encuentran los grupos, su contenido es añadido a la lista.|Una lista de objetos de FreeCAD}}

{{APIFunction/es|getRealName|string|Quita los números de rastreo a partir de un nombre de objeto.|El nombre del objeto desnudado}}

{{APIFunction/es|getSelection| |Devuelve la selección actual de FreeCAD.|La selección actual de FreeCAD.}}

{{APIFunction/es|makeCircle|radius, [placement], [facemode], [startangle], [endangle]|Crea un objeto circunferencia con un radio dado. Si se indica una ubicación, se utiliza. Si facemode es False, la circunferencia se muestra como una polilínea, en otro caso como una cara. Si startangle y endangle se indicad (in grados), se utilizan y el objeto aparece como un arco.|El nuevo objeto creado.}}

{{APIFunction/es|makeDimension|Vector, Vector, [Vector] o FreeCAD.Object, int, int, [Vector]|Creates un objeto Dimension o Cota midiendo la distancia entre el primer y segundo vector, con la línea de cota pasando por el tercer vector si se indica. Se utilizará el ancho de línea y el color actuales. En lugar de 2 vectores, puedes pasarle un objeto de FreeCAD, y dos enteros (y opcionalmente un vector por donde la línea de cota debe pasar). En este caso, la dimensión se asociará con el objeto, y medirá dos de sus vértices, indicados por los dos números de índice.|El nuevo objeto creado.}}

{{APIFunction/es|makeLine|Vector, Vector|Crea una línea entre los dos objetos dados. Se utilizará el ancho de línea y color de la barra de herramientas de Borrador.|El nuevo objeto creado.}}

{{APIFunction/es|makeRectangle|length, width, [placement], [facemode]|Crea un objeto rectángulo con longitud en dirección X y altura en dirección Y. Si se indica una ubicación, se utiliza. Si facemode es False, el rectángulo se muestra como una polilínea, en caso contrario como una cara. Se utilizan el ancho de línea y color de la barra de herramientas de Borrador.|El nuevo objeto creado.}}

{{APIFunction/es|makeText|string o list, [Vector], [screenmode])|Crea un objeto de texto, en la posición indicada si se proporciona un vector, conteniendo la cadena de texto o cadenas dadas en la lista, una cadena de texto por línea. Se utilizan el color actual de la barra de herramientas Borrador y la altura de texto y fuente especificadas en las preferencias. Si screenmode es True, el texto siempre mira en la dirección de la vista, en otro caso se sitúa sobre el plano XY.|El nuevo objeto creado.}}

{{APIFunction/es|makeWire|list o Part.Wire, [closed], [placement], [facemode]|Crea un objeto polilínea a partir de la lista de vectores indicada o a partir de la polilínea indicada. Si closed es True o si el primer y último punto son idénticos, la polilínea es cerrada. Si facemode es True (y la polilínea es cerrada), la polilínea se mostrará rellena. Se utilizará el ancho de línea y color de la barra de herramientas Borrador.|El nuevo objeto creado.}}

{{APIFunction/es|move|FreeCAD.Object o list, Vector, [copymode])|Mueve el objeto dado o los objetos contenidos en la lista dada en la direccióny distancia indicada por el vector dado. Si copymode es True, el objeto actual no se mueve, sino que se crea una copia en su lugar.|Los objetos (o sus copias si copymode era True).}}

{{APIFunction/es|precision| |Devuelve el valor de precisión de la configuración del usuario para el borrador.|Un entero.}}

{{APIFunction/es|rotate|FreeCAD.Object o list, angle, [center], [axis] ,[copymode]|Gira el objeto dado o los objetos contenidos en la lista indicada con el ángulo dado alrededor del centro si es indicado, utilizando eje como eje de rotación. Si se omite el eje, la rotación será alrededor del eje Z. Si copymode es True, los objetos actuales no se mueven, sino que se crea una copia en su lugar.|El objeto (o sus copias).}}

{{APIFunction/es|scale|FreeCAD.Object o list, vector, [center], [copymode]|Escala el objeto dado o los objetos contenidos en la lista dada con un factor de escala definido por el vector dado (en las direcciones X, Y y Z) alrededor del centro dado si es proporcionado. Si copymode es True, el objeto actual no se mueve, sino que se crea una copia en su lugar.|Los objetos (o sus copias).}}

{{APIFunction/es|select|FreeCAD.Object|Deselecciona todo y selecciona solo el objeto pasado|Nada.}}

{{APIFunction/es|shapify|FreeCAD.Object|Transforma una objeto forma paramétricas en no paramétrico.|El nuevo objeto.}}

{{APIFunction/es|draftify|FreeCAD.Object o list|Cambia el objeto dado o cada objeto de la lista dada en polilíneas paramétricas del borrador.|Nada.}}

{{APIFunction/es|getSVG|FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)]|Crea una representación SVG de los objetos dados. El atributo linemodifier es un factor de escala (en porcentajes) para el ancho de línea, y textmodifier para la altura del texto. También puedes opcionalmente proporcionar una tupla de vectores para definir una proyección plana, en otro caso la geometrís se proyectará sobre el plano XY.|Una cadena de texto conteniendo una representación SVG del objeto dado.}}


[[Category:API/es]]

{{languages/es | {{en|Draft API}} {{fr|Draft API/fr}} {{it|Draft API/it}} {{ru|Draft API/ru}} {{se|Draft API/se}} }}

[[Category:Poweruser Documentation/es]]

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.