panel vars ?

i did a small panel
where i define and seleted obj
then define a few variables

now what would be the best way to pass these var to a custom operator where i call a function?

one way would be to define all the vars as global but is there a better or another way may be ?

thanks

add the same properties to the operator and pass them from panel to operator like:

props = layout.operator("…")
props.your_prop = “String property passed on”
props.foobar = 1337

not really following here!

here is the operator
which i’m calling right now with
layout.operator(“custom.button1”)

&&&&

class custombutton1(bpy.types.Operator):

bl_idname = “custom.button1”
bl_label = “Custom Button”
doc = “Simple Custom Button”

def invoke(self, context, event):

obj = bpy.context.object
ang1=bpy.context.scene.MyFloat1

RotateAboutPoint(obj, point1, (0,0,1), ang1) # Rotate Object

%%%%

last line is the call to a function needing some vars

how do you pass the prop to the operator?

i’m calling the operator class with a button
so when i click it does it only ounce not repeating like if it was in the panel itself
cause that has to change the mesh data only ounce otherwise it goes like into a loop!

si need to pass the ob then a vector ect

thanks

like this:

###############
# Panel code       #
###############
layout.prop(context.scene, "MyFloat1")

prop = layout.operator("custom.button1")
prop.ang1 = context.scene.MyFloat1 ###### PASS MyFloat1 value TO OPERATOR #####

###############
# Operator code  #
###############

class custombutton1(bpy.types.Operator):
     """"Simple Custom Button"""
     bl_idname = "custom.button1"
     bl_label = "Custom Button"

     ang1 = bpy.props.FloatProperty() #### OPERATOR PROPERTY, NOT GLOBAL PROPERTY! ####

     def execute(self, context):
        obj = bpy.context.object
        RotateAboutPoint(obj, point1, (0,0,1), self.ang1) # Rotate Object

first var ang1 seems to work !

also is it possible pass the OBJ or have to use global var for this
and i have a vector var
so is there a prop for vector also?

thanks

i tought that blender class had some restrictions or constraints
did not know you could do that with an operator class
will have to remember that one!

so here you are instantiating the operator and defining class vars in it!

hope we can define vector and object too!

thanks

i added a new vector prop
now one problem here

when you add prop you can specify some default values
but if you change these values in the panel and then save file
when you re upload these saved values will be use instead of the default value
so is there a way to cancel the saved values and use the default values instead?

thanks

is it possible pass the OBJ

What OBJ? You can only use the available bpy.props properties, a stringprop for a filename would work.

when you re upload these saved values

Reopen you mean? Well, i guess you need to add the SKIP_SAVE option for the properties in the panel, then it shouldn’t save them.

Otherwise, you could provide an operator / button to restore defaults. You can read out the default values from global props btw:
bpy.types.Scene.your_prop[1][‘default’]

??? ???,mcm ???2009??? ??? ???·???·???1951?3?24??? ??? ???worldfamous???,Fendi ?? ???? BiographyHilfiger?1951?3?24???,???? ??? ??? ??? ???,??? ??? ??? ???,??? ?? ???? ???,MIU MIU ???? ??? ???10???,Fendi ?? ???? ??? ???.. ???30???15???15???,prada ???? ???Hulu?Plus??? ???,??? ?? ???? ???obtain,??? ?? ???.First???TEFL??? ??? ???,??? ?? ??? ???WTEFLAC?TEFL / TESOL???,??? ???? ???,prada ?? ???? ???: ??? ??? ??? ??? ???rusticfancy???

ok i can use the default prop values

but how do you add the SKIP_SAVE to panel
never use that one before!

for the ob in panel i did

obj = bpy.context.object

so wondering how to pass this obj to an operator and to a function inside the operator
is it through a string may be ?
cause this is an object not a string!

thanks

there are no IDProperties, so you can’t pass an actual object, but passing it by name should be fine

layout.operator(“object.foobar”).object = bpy.context.object.name

this might be a bit problematic with linked objects, as they can have the same name.

The property option is set at registration, e.g.

bpy.types.Scene.p = bpy.props.BoolProperty(name=“Foobar”, options={‘SKIP_SAVE’})

i can always make it as a global var

thanks