panel and mesh update only ?

if i do a tool pro panel with several variables
is there a way to update the mesh only and not create a new object when vars are changed?

any example of such a code snippet ?

or do i have to add at bottom of panel an operator button to implemente this feature
like we can do with add mesh menu !

thanks

that seems tricky, as you could easily destroy the mesh…

import bpy


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"

    def draw(self, context):
        layout = self.layout

        obj = context.object

        layout.prop(context.scene, "p")


def cb(self, context):
    diff = context.scene.p - context.scene.pp
    
    for vert in context.object.data.vertices:
        vert.co.x += diff
        
    context.scene.pp = context.scene.p

def register():
    bpy.utils.register_class(HelloWorldPanel)
    bpy.types.Scene.p = bpy.props.IntProperty(min=0, max=10, update=cb)
    bpy.types.Scene.pp = bpy.props.IntProperty(min=0, max=10)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)
    del bpy.types.Scene.p
    del bpy.types.Scene.pp


if __name__ == "__main__":
    register()


why is it so easy to do with add mesh menu scripts?

and is it good practice to add delete props in reg functions ?

why do you say it could destroy the object ?
is not there a normal stable way of doing this

i have some complicated calculations (diffuse equations) i need to do functions of many variables
and it will change how the data is shown

the data for verts is not the same each tme it is more like an animation of verts
over time until it converges to a final shape (diffuse equations over time)

or should i go with an add mesh script instead

and / or may be end up doing a small animation with driver and keyframes

thanks

i like the idea of parametric
saw one or 2 like that
but find it much more complicated !

how do you add a new one ?
is it possible to have more then one parametric object ?

mind you that it might be easier to do it with the add mesh menu style may be!

only thing missing is to detect the object itsefl and continue with the script
but i saw something like that 2 years ago!

thanks

how do you add a new one ?

SHIFT-A. The AddOn registers itself with the Add menu.

is it possible to have more then one parametric object ?

Sure, because each object is a container for the parameters that define that object.

only thing missing is to detect the object itsefl and continue with the script

If the AddOn is set to always run under User Preferences it will detect the objects it needs to manage on scene load.

why is it so easy to do with add mesh menu scripts?

What you see in the sidebar is the redo panel with the operator properties. Changing values here will undo the operator and redo with new values. As soon as you run another operator, it won’t be possible to change those parameters again.

bl_options = {‘REGISTER’, ‘UNDO’} is required for the operator

i dont see thsi command in code snippet
where do i add this ?
in panel overhead?

thanks

to the operator class, below bl_idname and bl_label.

Operator Mesh Add template uses it. But note that you need to invoke the op in view3d in order to get the options in the redo panel, running from text editor won’t work.

where do you set or do the default value for prop

bpy.types.Scene.ncell = IntProperty(
name=“Number of cells”,
soft_min=4,
max= 10,
description=“Enter Number of cells”,
default=4)

bpy.types.Scene.ncell[1][‘default’]

and what is this 1 number ?

thanks

bpy.types.Scene.ncell = IntProperty(
    name="Number of cells",
   soft_min=4,
    max= 10,
    description="Enter Number of cells",
    default=4) # <--- HERE

something wrong here

problem is that if i save the file it does take default it will take new saved value from file!

you gave me that example before but did not use it

You can read out the default values from global props btw:
bpy.types.Scene.your_prop[1][‘default’]

panel are still a pain in the neck !

these panels are getting in the way too complicated for the script i’m doing
i’ll redo it with the add menu mesh instead
at least the mesh data is updated automaticaly
and easy to change prop
only problem might be the calculations time

for a diffusion equation with partiel differential equations
solve with difference equations

thanks

of course it reads the value from blend, that’s the point of properties. Use constants if you need it to be always 4.

of course it reads the value from blend, that’s the point of properties. Use constants if you need it to be always 4.

If you need a temp var in a panel to initialize to a certain value, see an example here:
http://code.google.com/p/blender-cod/source/browse/blender_26/init.py#417

i want the panel to run with the same props default value from the init part not the saved one from th file!

in other word i would have to add an init class to re init all props when it start to run
have to find that one again

for that script i may have to do that
i a user save file then the program might not work as it should !

salut

you don’t have to, use bpy.types.WindowManager or options={‘SKIP_SAVE’} in property registeration

you mean like htat
ncell1 = IntProperty(name=“No Cells”, description=“No Cells”, default=4, min=4, max=100,options={‘SKIP_SAVE’})

KT = FloatProperty(name=“KT”, description=“KT”,default=4, min=2, max=50,options={‘SKIP_SAVE’})
KP = FloatProperty(name=“KP”, description=“KP”,default=4, min=2, max=20,options={‘SKIP_SAVE’})

i have a class wtit 10 props for calculations

what is the best way to pass these vars to functions?
Global vars may be or pass prop into a dictionary !

this is for the add menu class

class Periodpattern1(bpy.types.Operator):

‘’‘Add Period Patterns’’’

bl_idname = “mesh.primitive_periodpat1_add”
bl_label = “Period Patterns”
bl_options = {‘REGISTER’, ‘UNDO’,‘BLOCKING’}

ncell1 = IntProperty(name=“No Cells”, description=“No Cells”, default=4, min=4, max=100,options={‘SKIP_SAVE’})
KT = FloatProperty(name=“KT”, description=“KT”,default=4, min=2, max=50,options={‘SKIP_SAVE’})
KP = FloatProperty(name=“KP”, description=“KP”,default=4, min=2, max=20,options={‘SKIP_SAVE’})

unless there is a way to make a scene prop too!

if you want to see math model
see PPT file here

http://www.eb.tuebingen.mpg.de/fileadmin/uploads/images/Research/emeriti/Hans_Meinhardt/ppt/How_to_write_a_program.ppt

thanks