Previous Thread  Next Thread

chat icon operator and buttons not working anymore? 2.62

mafster

Posted: Sat Mar 17, 2012 10:24 am
Joined: 17 Mar 2012
Posts: 4
Hi just using Blender 2.6, seem the custom operators aren't working for me...

Just tested with the pingpong script

import bpy
# version 1.3.0
# tested on 31315


class OBJECT_PT_pingpong(bpy.types.Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_label = "Ping Pong"

display = 0

def draw_header(self, context):
layout = self.layout
layout.label(text="", icon="PHYSICS")

def draw(self, context):
layout = self.layout
row = layout.row()
split = row.split(percentage=0.5)
colL = split.column()
colR = split.column()

if self.display == 0:
colL.operator("pipo", text="Ping")
else:
colR.operator("pipo", text="Pong")



bpy.utils.register_class(OBJECT_PT_pingpong)

This is all i get:



all my custom buttons are doing the same, just the txt and nothing to click. Any ideas? Is this 2.6 problem?
_________________
....interesting....
Reply with quote


ldo

Posted: Sun Mar 18, 2012 11:05 am
Joined: 07 Nov 2010
Posts: 544
What is “pipo”?
Reply with quote


mafster

Posted: Sun Mar 18, 2012 6:59 pm
Joined: 17 Mar 2012
Posts: 4
lol! sorry my bad....shoulda put the whole script. "pipo" is the class (Operator) id_name

class OBJECT_OT_pingpong(bpy.types.Operator):
bl_label = "PingPong operator"
bl_idname = "pipo"
bl_description = "Move the ball"

def invoke(self, context, event):
import bpy

self.report("INFO", "Moving the ball")
bpy.types.OBJECT_PT_pingpong.display = 1 - bpy.types.OBJECT_PT_pingpong.display
return{"FINISHED"}

thats what the previous def calls on.
_________________
....interesting....
Reply with quote


ldo

Posted: Mon Mar 19, 2012 1:49 am
Joined: 07 Nov 2010
Posts: 544
Your bl_idname probably needs a prefix which is one of the valid subcategories defined in bpy.ops, e.g. “object.pipo” rather than just “pipo”.

Also I wouldn’t bother giving your class a magic xx_OT_xx-type name—it serves no purpose.
Reply with quote


mafster

Posted: Mon Mar 19, 2012 7:42 am
Joined: 17 Mar 2012
Posts: 4
Hmm that didnt work for me, im wondering do i have to register the operator class as well?
Well anyway that didnt work either. Its strange if i use any of the operators already created e.g. "object.armature_add" then it pops out a button with any problemos.
Seems rather wierd was working on previous versions.

Smile fully agree with the whole magic thing...i wondered why so many people were doing that? Never used it in the past. Seems a bit convoluted to me

Well if anyone has had any luck with creating their own operators and having it run as a button would be keen to see your script
_________________
....interesting....
Reply with quote


ldo

Posted: Mon Mar 19, 2012 8:20 am
Joined: 07 Nov 2010
Posts: 544
Yes, you have to register your operators. You want to see some sample code that works? Have a lookt at this: https://github.com/ldo/gimp_palettes_for_blender.
Reply with quote


ldo

Posted: Mon Mar 19, 2012 8:26 am
Joined: 07 Nov 2010
Posts: 544
If you want a button example try this one: https://github.com/ldo/treadtiler.
Reply with quote


mafster

Posted: Mon Mar 19, 2012 8:51 am
Joined: 17 Mar 2012
Posts: 4
thanks peeps! mustv typed something wrong i tried again with register and it worked. Also had to have the operator sub category as well
_________________
....interesting....
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group