Macro Draw 2D Function/es: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
(12 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
{{Macro|Icon=Text-x-python|Name=Draw 2D Function|Description=Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)|Author=unknown}} |
|||
{{Macro/es |
|||
|Name=Draw 2D Function |
|||
|Translate=Draw 2D Function |
|||
|Icon=Macro_Draw_2D_Function.png |
|||
|Description= Utilízala para dibujar una función descrita por una "ecuación" [z=F(x)] (Z-X plano) |
|||
|Author=unknown |
|||
|Version=1.0 |
|||
|Date=2011-08-01 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/3/36/Macro_Draw_2D_Function.png ToolBar Icon] |
|||
}} |
|||
==Descripción== |
|||
Utilízala para dibujar una función descrita por una "ecuación" [z=F(x)] (Z-X plano) El ejemplo indicado aquí genera una parábola. |
Utilízala para dibujar una función descrita por una "ecuación" [z=F(x)] (Z-X plano) El ejemplo indicado aquí genera una parábola. |
||
Line 15: | Line 27: | ||
ZZ=Función expresada express con xx |
ZZ=Función expresada express con xx |
||
==Script== |
|||
ToolBar Icon [[Image:Macro_Draw_2D_Function.png]] |
|||
<syntaxhighlight> |
|||
'''Macro_Draw_2D_Function.FCMacro''' |
|||
{{MacroCode|code= |
|||
# F = variable used in the function, |
# F = variable used in the function, |
||
Line 36: | Line 53: | ||
ZZ=XX*XX/(4*F) |
ZZ=XX*XX/(4*F) |
||
if I==0: |
if I==0: |
||
print "Le test est vrai !" |
print( "Le test est vrai !") |
||
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) |
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) |
||
WWire=Part.Wire([nomme]) |
WWire=Part.Wire([nomme]) |
||
else : |
else : |
||
print "Le test est 2 !" |
print( "Le test est 2 !") |
||
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) |
nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) |
||
WWire=Part.Wire([WWire,nomme]) |
WWire=Part.Wire([WWire,nomme]) |
||
Line 47: | Line 64: | ||
Part.show(WWire) |
Part.show(WWire) |
||
}} |
|||
</syntaxhighlight> |
|||
⚫ |
Latest revision as of 10:16, 23 May 2020
Descripción |
---|
Utilízala para dibujar una función descrita por una "ecuación" [z=F(x)] (Z-X plano) Versión macro : 1.0 Fecha última modificación : 2011-08-01 Versión FreeCAD : All Descargar : ToolBar Icon Autor : unknown |
Autor |
unknown |
Descargar |
ToolBar Icon |
Enlace |
Macros recipes How to install macros How to customize toolbars |
Versión Macro |
1.0 |
Fecha última modificación |
2011-08-01 |
Versión(es) FreeCAD |
All |
Acceso directo predeterminado |
None |
Ver también |
None |
Descripción
Utilízala para dibujar una función descrita por una "ecuación" [z=F(x)] (Z-X plano) El ejemplo indicado aquí genera una parábola.
Necesita ser definida:
F=variable utilizada en la función,
X=Valor inicial de x,
Nb= Número de pasos,
Z=Función expresada express con x
ZZ=Función expresada express con xx
Script
Macro_Draw_2D_Function.FCMacro
# F = variable used in the function, # X = initial value of x, # Nb = Number of step, # Z = function express with x # ZZ = function express with xx import FreeCAD, FreeCADGui, Part import math F=800 X=-500 Nb=10 Step=1000/Nb Y=0 for I in range(Nb): XX=X+Step Z=X*X/(4*F) ZZ=XX*XX/(4*F) if I==0: print( "Le test est vrai !") nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) WWire=Part.Wire([nomme]) else : print( "Le test est 2 !") nomme=Part.makeLine((X,Y,Z),(XX,Y,ZZ)) WWire=Part.Wire([WWire,nomme]) X=XX Part.show(WWire)