PDA

View Full Version : scriptCtx using python


LuizElias
02-18-2011, 06:15 PM
Hi,
Im trying to do a scriptCtx using python but the "finalCommandScript" flag is not calling the comand I want to use, does anyone knows what is wrong? here is the code:

import maya.cmds as cmds

def printer():
print "aaaa"

if cmds.scriptCtx("printer",exists=1):
cmds.deleteUI("printer")

cmds.scriptCtx(
"printer",
totalSelectionSets = 1,
title = "printer",
i1 = "blendSurface.xpm",
toolCursorType = "create",
setAutoToggleSelection = 1,
setSelectionCount = 2,
finalCommandScript = ("printer()")
)

cmds.setToolTo("printer")


thanks!

dbsmith
02-20-2011, 08:29 PM
Try changing this line:
finalCommandScript = ("printer()")
to
finalCommandScript = printer

and it should refer to the python function object. You may want to rename your method, so its a different name than your actual scriptCtx too

LuizElias
02-21-2011, 10:49 AM
thanks for your reply!

but it still not working for me..

you mean something like this?


import maya.cmds as cmds

def myFun():
cmds.polySphere()

if cmds.scriptCtx("myScriptCtx",exists=1):
cmds.deleteUI("myScriptCtx")

cmds.scriptCtx(
"myScriptCtx",
totalSelectionSets = 1,
setAutoToggleSelection = 1,
setSelectionCount = 2,
finalCommandScript = myFun
)

cmds.setToolTo("myScriptCtx")

CGTalk Moderation
02-21-2011, 10:49 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.