Macro Draw 2D Function/it: Difference between revisions
m (Created page with "{{Macro/it|Icon=Text-x-python|Name=draw2DFunction|Name/it=draw2DFunction|Description= Si usa per disegnare una funzione descritta da una equazione z=F(x) (piano Z-X)|Author=ig...") |
(Updating to match new version of source page) |
||
(20 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
⚫ | |||
{{Macro/it |
|||
|Name=Draw 2D Function |
|||
|Translate=Draw 2D Function |
|||
|Icon=Macro_Draw_2D_Function.png |
|||
|Translate=Funzione 2D |
|||
⚫ | |||
|Author=ignoto |
|||
|Version=1.0 |
|||
|Date=2011-08-01 |
|||
|FCVersion=Tutte versione |
|||
|Download=[https://www.freecadweb.org/wiki/images/3/36/Macro_Draw_2D_Function.png Icona per la ToolBar] |
|||
}} |
|||
==Description== |
|||
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) The example done here generate a parabol.<br /> |
|||
Si usa per disegnare una funzione descritta da una equazione [z=F(x)] (piano ZX). Questo esempio genera una parabola. |
|||
Needs to be defined :<br /> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Elementi da definire: |
|||
:F=variable utilizzata nella funzione, |
|||
<syntaxhighlight> |
|||
⚫ | |||
:X=Valore iniziale di x, |
|||
⚫ | |||
⚫ | |||
:Nb= Numero di passi, |
|||
⚫ | |||
⚫ | |||
:Z=Funzione espressa con x |
|||
⚫ | |||
⚫ | |||
:ZZ=Funzione espressa con xx |
|||
⚫ | |||
⚫ | |||
==Script== |
|||
ToolBar Icon [[Image:Macro_Draw_2D_Function.png]] |
|||
'''Macro_Draw_2D_Function.FCMacro''' |
|||
{{MacroCode|code= |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Z=X*X/(4*F) |
Z=X*X/(4*F) |
||
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]) |
||
X=XX |
X=XX |
||
Part.show(WWire) |
|||
}} |
|||
</syntaxhighlight> |
|||
⚫ |
Revision as of 10:16, 23 May 2020
Descrizione |
---|
Si usa per disegnare una funzione descritta da una equazione z=F(x) (piano Z-X) Versione macro: 1.0 Ultima modifica: 2011-08-01 Versione FreeCAD: Tutte versione Download: Icona per la ToolBar Autore: ignoto |
Autore |
ignoto |
Download |
Icona per la ToolBar |
Link |
Raccolta di macro Come installare le macro Personalizzare la toolbar |
Versione macro |
1.0 |
Data ultima modifica |
2011-08-01 |
Versioni di FreeCAD |
Tutte versione |
Scorciatoia |
Nessuna |
Vedere anche |
Nessuno |
Description
Si usa per disegnare una funzione descritta da una equazione [z=F(x)] (piano ZX). Questo esempio genera una parabola.
Elementi da definire:
- F=variable utilizzata nella funzione,
- X=Valore iniziale di x,
- Nb= Numero di passi,
- Z=Funzione espressa con x
- ZZ=Funzione espressa 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)