Macro Draw 2D Function/it: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 17: Line 17:


<syntaxhighlight>
<syntaxhighlight>

import FreeCAD, FreeCADGui, Part
import math
import FreeCAD, FreeCADGui, Part
import math
F=800
F=800
X=-500
X=-500
Nb=10
Nb=10
Step=1000/Nb
Step=1000/Nb
Y=0
Y=0
for I in range(Nb):
for I in range(Nb):
XX=X+Step
XX=X+Step
Z=X*X/(4*F)
Z=X*X/(4*F)
ZZ=XX*XX/(4*F)
ZZ=XX*XX/(4*F)
Line 38: Line 39:
X=XX
X=XX
Part.show(WWire)
Part.show(WWire)


</syntaxhighlight>
</syntaxhighlight>

Revision as of 20:23, 4 May 2014

File:Text-x-python draw2DFunction

Descrizione
Si usa per disegnare una funzione descritta da una equazione z=F(x) (piano Z-X)

Autore: ignoto
Autore
ignoto
Download
None
Link
Versione macro
1.0
Data ultima modifica
None
Versioni di FreeCAD
None
Scorciatoia
Nessuna
Vedere anche
Nessuno

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


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)