Atoms bear parm script, adusting to XYZ mesh .. to animate a XYZ-function surface

It looks like I am a sorcerers apprentice, doing but not really knowing what I do … :evilgrin:

But to some degree succeeded already:
There are three objects-types in the picture.
The startup Cube, the default XYZ (the shell) object and and a third created by by Alt A
(the frame rate used to change location, will become more complicated …)
(the drivers result) different (because in an UI the x_eq is replaced by something simple)

What I need to accomplish: remove old newly created objects and make it ‘animate’ …

My horrible script can be seen here: http://www.petergragert.info/pmwiki/pmwiki.php/Animation/XYZVersion01

Attachments


I think it looks real cool!

One thing that will not work is your use of the the context in line # 455 and other places in the script.

bpy.context.scene.objects.link(ob)
While it will work during GUI operations (i.e. under the MainThread) it will fail when you try to render an animation sequence (in a Dummy thread) or with Yafaray.

Rewrite the line like this…

bpy.data.scenes[0].objects.link(ob)

The fall out of this re-write is that you will be operating upon scene #0 explicitly. If you have multiple scenes in your project, the animated objects must reside in scene #0 for them to render.

That is what def returnScene is all about.


def returnScene (passedIndex = 0):
    try:
        return bpy.data.scenes[passedIndex]
    except:
        return None

myScene = returnScene()  #Note: I could pass an alternate index here.
if myScene != None:
     myScene.objects.link(ob)
else:
   # I am probably rendering.
    pass

By making all your scene references via returnScene, you can simply alter the pass index in one place (or forward it from a custom property in your object) to render animated objects that reside in difference scenes.

NOTE: The frameChange addon is actually a two part script. The AddOn portion installs the frame change processing script. So you can use the context in the AddOn portion of the script (i.e. initial object creation), but you can not use the context in the runtime frame change portion. Any code that resides in the doc portion of the code def of the AddOn.

Thanks for looking!
That it is a two parts script is clear: the doc of def code() is used … (there I prefixed defs with pkhg_, to see the difference).

Only one scene (nr. 0) is OK for me (at least now).

bpy.data.scenes[0].objects.link(ob) helps a little bit …???
Thus I do not understand this problem (yet)

I did try out your script, but it did not seem to do anything?

Presently I am running on a Mac, so I have no console to look at to view any error messages. I’ll try again, later, on Windows.

Ok,

I had a chance to take a look at the code and I got it working. I simplified it quite a bit. Basically this is a straight port of the Beam AddOn with the beam generation code replaced by your pkhg_xyz_function_surface_faces mesh generator

One thing I noticed is that you were trying to make it work like a “Tool” add on. Frame change based objects do not work that way. We don’t use scene based properties because our frame change script may manage multiple objects, each with their own parameter set. All the frame change based AddOn does is create the initial object, install the frame change script (if it does not already exist) and it is done. The frame change script gets called and updates the mesh. There is no need to create a new object, ever, in a frame change script. The frame change script creates new meshes on-the-fly and links them to an existing object which hold the custom properties that define the mesh for that moment in time. Remember, the frame change script is managing existing objects based upon a naming convention. If you start passing “unofficial” names to creation routines you are bound to end up with errors or memory leaks.

As far as creating panels, I don’t bother, I simply animate the properties of the managed object directly. This does not mean, you can not create panels to help out with that animation task. And in this case, especially with those equations, you may need some panel based mechanism to recalculate the user input against PI.

If you are going to create panels, they should be created under the PROPERTIES space type not VIEW_3D.


    # Panel
    bl_label = "XYZ Equation"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"   #HEADER
    bl_context = "object"
    bl_options = 'DEFAULT_CLOSED'

Attachments

25_parm_pkgh_xyz_addon.blend (173 KB)


Wow, THAT is what I wanted to accomplish
Thanks a lot Atom!

(And now trying to understand totally :yes:)

I have to find out (from your .blend) where you manipulate the two objects via framechange.

If I use the addon addon_parm_xyz_eq.py alone in a fresh Blender it creates the shell (default) but NO animation is done
so Peter: search for it!

EDIT
Ahh, I see, there are Actions for your two objects.
How did you create them??? That is probably my 'NOT KNOWLEDGE" :evilgrin:

I created the animation by just key framing the custom properties on the managed object.

You can alter the formula as well, but it appears that strings are not animatable.

reviewParametricXYZ is the function that process all managed objects. It calls a function returnObjectNamesLike with the OBJECT_PREFIX string that identifies the object this script is managing. This produces a list as a result. The list contains the names of the objects that have been detected for management. The object is fetched and custom properties are examined and or passed to a mesh generation function that should return a mesh. The existing mesh is fetched. The materials from the existing mesh are transferred to the newly generated mesh. The existing mesh is replaced with the new mesh.

OK, now it is clear, I tryed to set a keyframe on one of that objects parameter values … but it showed no “Insert …” but now it does.
Reason of my (earlier) error, unknown…

http://petergragert.info/images/Blender/GIF/shellaniOK.gif

Jippie, only one mini problem (5%) to be solved … to use a parameter to change the shape IN an animation …

Reason found: I tried to insert a keyframe for a StringProperty, and that is not possible!

Hi Atom, here is a very interesting .blend in the context of what you accomplished
http://www.pasteall.org/blend/6422
It is driver driven counter from to etc.
In 3dView it runs perfectly showing so to say a counter
BUT the Animation show only ONE image and not what you see in 3dview … it looks like you know how to change that and I am very curious to understand … :slight_smile: