3D Function Surface script (Blender 2.5x)

UPDATE 2011-06-26
This script has been integrated into the “Extra Objects” Add-On already included into Blender.

Simply activate that script and you are good to go.
Add -> Extra Objects -> Math Function

Old Post content:

Had some time to play around with mesh creation code again.
This script lets the user create a (mesh) surface where the z coordinate is a function of the x and y coordinates.

z = f(x,y)

Blender 2.5x
Link to the script
(Save the “Raw data blob” link there as a file into your .blender/scripts/addons/ directory)
You can then enable the plugin in the User Preferences under Add-Ons.

Direct download link to the most recent version (Blender2.5):
http://gitorious.org/blender-scripts/blender-3d-function-surface/blobs/raw/master/add_mesh_3d_function_surface.py

Once installed, the script is available from the Add Mesh -> 3D Function Surface menu.

Script homepage
http://gitorious.org/blender-scripts/blender-3d-function-surface

Cheers,
Martin

Hi, script looks great, I have been trying to program a script for 2.49 but have found it quite difficult, how have you found it writing this for 2.5? Easier? How did you learn? any resources you can share?

thanks

@mandoragon
The text below assumes you already know hwo to use Python…

To me programming for 2.49 is roughly the same “difficulty level” as programming for 2.5.
But 2.5 has some nice new feature and concepts that help with streamlining the process a bit (but it also has some unfinished stuff of course).

I mainly use the following resources (most of them are referred to in this forum in various places):

Martin

Thanks for sharing, saved me a tonne of rooting around old docs and dead threads.:spin:

not to be a hijacker… this looks great Martin, close to what I need right now.
take a peek at this thread: http://blenderartists.org/forum/showthread.php?t=179127

It may look close, but it’s something quite different internally.
I’m actually creating new geometry each time the equation is changed (or rather: Blender does) - there is no modification of geometry.
I doubt the code (except for the equation/formula evaluation part) can be used for a wave-like modifier.

Martin

Unless of course instead of making a new vertex, at initialisation you could make an array of vertex the size and resolution of the mesh and have a loop assigning them depending on the function? that would also allow you to have it change with time

What a nice script, fun to play with, and very educational too. Thank you!

I was thinking of getting a gitorious account for scripting, why did you choose it over other svn systems?

Neat script… Thanks for sharing… :slight_smile:

I use git, not svn :slight_smile:
Gitorious had the easiest account setup/usage from the 2 or 3 git hosts I tried. I used it since I created my account.
That also means, that I can’t really say if other hosts do anything better or worse than gitorious. I don’t know them as well.

Martin

what other hosts did you look at?

One of them was http://github.com/, I don’t really remember the other one(s), sorry.
I guess searching the web will probably return it/them among others.

Martin

hi, hows this progressing?

As far as I’m concerned the script is done - unless there are any bugs I didn’t find yet.

EDIT: That said, I just saw that I didn’t upload the most recent code here (some security stuff for the eval function).
Updated version post follows in a minute.

Cheers,
Martin

Version 0.2 of the script is now available.
Nothing visible to the user has been added.

  • Added security check for eval() function
  • Check return value of eval() for complex numbers -> they are ignored.

Download links are available in the original post

Martin

This is great. Thanks for sharing. Scripting is an huge power for Blender 2.5x series.

Wow great!:wink:
How about an preset tab with saving own definitions?

Hm, I’m pretty sure this isn’t possible with the current way the script asks for the equation text.

I’d need to actually create a GUI that calls the operator which then could display/define the presets. Even then you can only use the presets when creating the geoemtry the first time - but now when re-doing.

For now this is too much work for little benefit IMO, but I’ll look into this anyway.

Martin

hi there…gud to see u all here…