Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code when executed creates an icon and a description, clicking on the icon executes the code. Perfect!!! goes everything up to that moment.
I close Maya and open a new section of Maya, I click on the script icon and I get an error.
it's the first time something like this has happened to me... 😲
# Error: NameError: file <maya console> line 1: name 'createScriptJob' is not defined
the code:
import maya.cmds as mc
import maya.cmds as cmds
import maya.mel as mel
topShelf = mel.eval('$nul = $gShelfTopLevel')
currentShelf = mc.tabLayout(topShelf, q=1, st=1)
# Store the scriptJob ID
job_num = None
def updateGraphEditor():
# Get the current playback range
min_time = cmds.playbackOptions(query=True, minTime=True)
max_time = cmds.playbackOptions(query=True, maxTime=True)
# Set the playback range in the graph editor
cmds.animView("graphEditor1GraphEd", edit=True, startTime=min_time, endTime=max_time)
def createScriptJob():
global job_num
# Create the scriptJob
job_num = cmds.scriptJob(event=["playbackRangeChanged", updateGraphEditor])
print("ScriptJob created with ID: " + str(job_num))
def deleteScriptJob():
global job_num
if job_num:
cmds.scriptJob(kill=job_num)
print("ScriptJob with ID: " + str(job_num) + " deleted")
job_num = None
else:
print("No scriptJob to delete")
mc.shelfButton(parent=currentShelf, i='commandButton.xpm', c='createScriptJob()', dcc='deleteScriptJob()', iol= "Range")
Solved! Go to Solution.