Macro Draw 2D Function

From FreeCAD Documentation
Revision as of 17:44, 1 August 2011 by Yorik (talk | contribs) (Created page with '{{Macro|Name=draw2DFunction|Description=Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)}} Use it to draw a function described by a "equation" [z=F(x)] (…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Generic macro icon. Create your personal icon with the same name of the macro draw2DFunction

Description
Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane)

Author
[[User:{{{Author}}}|{{{Author}}}]]
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None


Use it to draw a function described by a "equation" [z=F(x)] (Z-X plane) The example done here generate a parabol.

Needs to be defined :

F=variable used in the fonction,

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)