Go to: Synopsis. Return value. Flags. Python examples.

Synopsis

scriptCtx( string , [allComponents=boolean], [allObjects=boolean], [animBreakdown=boolean], [animCurve=boolean], [animInTangent=boolean], [animKeyframe=boolean], [animOutTangent=boolean], [baseClassName=string], [camera=boolean], [cluster=boolean], [collisionModel=boolean], [controlVertex=boolean], [cumulativeLists=boolean], [curve=boolean], [curveKnot=boolean], [curveOnSurface=boolean], [curveParameterPoint=boolean], [dimension=boolean], [dynamicConstraint=boolean], [edge=boolean], [editPoint=boolean], [emitter=boolean], [enableRootSelection=boolean], [escToQuit=boolean], [exists=boolean], [exitUponCompletion=boolean], [expandSelectionList=boolean], [facet=boolean], [field=boolean], [finalCommandScript=script], [fluid=boolean], [follicle=boolean], [forceAddSelect=boolean], [hairSystem=boolean], [handle=boolean], [history=boolean], [hull=boolean], [ignoreInvalidItems=boolean], [ikEndEffector=boolean], [ikHandle=boolean], [image1=string], [image2=string], [image3=string], [imagePlane=boolean], [implicitGeometry=boolean], [isoparm=boolean], [joint=boolean], [jointPivot=boolean], [lastAutoComplete=boolean], [lattice=boolean], [latticePoint=boolean], [light=boolean], [localRotationAxis=boolean], [locator=boolean], [locatorUV=boolean], [locatorXYZ=boolean], [nCloth=boolean], [nParticle=boolean], [nParticleShape=boolean], [nRigid=boolean], [name=string], [nonlinear=boolean], [nurbsCurve=boolean], [nurbsSurface=boolean], [objectComponent=boolean], [orientationLocator=boolean], [particle=boolean], [particleShape=boolean], [plane=boolean], [polymesh=boolean], [polymeshEdge=boolean], [polymeshFace=boolean], [polymeshFreeEdge=boolean], [polymeshUV=boolean], [polymeshVertex=boolean], [polymeshVtxFace=boolean], [rigidBody=boolean], [rigidConstraint=boolean], [rotatePivot=boolean], [scalePivot=boolean], [sculpt=boolean], [selectHandle=boolean], [setAllowExcessCount=boolean], [setAutoComplete=boolean], [setAutoToggleSelection=boolean], [setDoneSelectionPrompt=string], [setNoSelectionHeadsUp=string], [setNoSelectionPrompt=string], [setSelectionCount=int], [setSelectionHeadsUp=string], [setSelectionPrompt=string], [showManipulators=boolean], [spring=boolean], [springComponent=boolean], [stroke=boolean], [subdiv=boolean], [subdivMeshEdge=boolean], [subdivMeshFace=boolean], [subdivMeshPoint=boolean], [subdivMeshUV=boolean], [surfaceEdge=boolean], [surfaceFace=boolean], [surfaceKnot=boolean], [surfaceParameterPoint=boolean], [surfaceRange=boolean], [surfaceUV=boolean], [texture=boolean], [title=string], [toolCursorType=string], [toolFinish=script], [toolStart=script], [totalSelectionSets=int], [vertex=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

scriptCtx is undoable, queryable, and editable.

This command allows a user to create their own tools based on the selection tool. A number of selection lists can be collected, the behaviour of the selection and the selection masks are fully customizable, etc.

The command is processed prior to being executed. The keyword "$Selection#" where # is a number 1 or greater specifies a selection set. The context can specify several selection sets which are substituted in place of the $Selection# keyword in the form of a Mel string array. Items that are specific per set need to be specified in each set, if they are going to be specified for any of the sets. See examples below.

In addition, in order to specify the type of selection you need to be making, any of the selection type flags from "selectType" command can be used here.

Return value

stringContext name

In query mode, return type is based on queried flag.

Flags

allComponents, allObjects, animBreakdown, animCurve, animInTangent, animKeyframe, animOutTangent, baseClassName, camera, cluster, collisionModel, controlVertex, cumulativeLists, curve, curveKnot, curveOnSurface, curveParameterPoint, dimension, dynamicConstraint, edge, editPoint, emitter, enableRootSelection, escToQuit, exists, exitUponCompletion, expandSelectionList, facet, field, finalCommandScript, fluid, follicle, forceAddSelect, hairSystem, handle, history, hull, ignoreInvalidItems, ikEndEffector, ikHandle, image1, image2, image3, imagePlane, implicitGeometry, isoparm, joint, jointPivot, lastAutoComplete, lattice, latticePoint, light, localRotationAxis, locator, locatorUV, locatorXYZ, nCloth, nParticle, nParticleShape, nRigid, name, nonlinear, nurbsCurve, nurbsSurface, objectComponent, orientationLocator, particle, particleShape, plane, polymesh, polymeshEdge, polymeshFace, polymeshFreeEdge, polymeshUV, polymeshVertex, polymeshVtxFace, rigidBody, rigidConstraint, rotatePivot, scalePivot, sculpt, selectHandle, setAllowExcessCount, setAutoComplete, setAutoToggleSelection, setDoneSelectionPrompt, setNoSelectionHeadsUp, setNoSelectionPrompt, setSelectionCount, setSelectionHeadsUp, setSelectionPrompt, showManipulators, spring, springComponent, stroke, subdiv, subdivMeshEdge, subdivMeshFace, subdivMeshPoint, subdivMeshUV, surfaceEdge, surfaceFace, surfaceKnot, surfaceParameterPoint, surfaceRange, surfaceUV, texture, title, toolCursorType, toolFinish, toolStart, totalSelectionSets, vertex
Long name (short name) Argument types Properties
allComponents(alc) boolean createquerymultiuse
Set all component selection masks on/off
allObjects(alo) boolean createquerymultiuse
Set all object selection masks on/off
animBreakdown(abd) boolean createquerymultiuse
Set animation breakdown selection mask on/off.
animCurve(ac) boolean createquerymultiuse
Set animation curve selection mask on/off.
animInTangent(ait) boolean createquerymultiuse
Set animation in-tangent selection mask on/off.
animKeyframe(ak) boolean createquerymultiuse
Set animation keyframe selection mask on/off.
animOutTangent(aot) boolean createquerymultiuse
Set animation out-tangent selection mask on/off.
baseClassName(bcn) string createqueryedit
This string will be used to produce MEL function names for the property sheets for the tool. For example, if "myScriptTool" was given, the functions "myScriptToolValues" and "myScriptToolProperties" will be used for the property sheets. The default is "scriptTool".
camera(ca) boolean createquerymultiuse
Set camera selection mask on/off. (object flag)
cluster(cl) boolean createquerymultiuse
Set cluster selection mask on/off. (object flag)
collisionModel(clm) boolean createquerymultiuse
Set collision model selection mask on/off. (object flag)
controlVertex(cv) boolean createquerymultiuse
Set control vertex selection mask on/off. (component flag)
cumulativeLists(cls) boolean createqueryedit
If set, the selection lists will be cumulative. For example, the second list will contain all the items from the first list, the third all the items from the second list etc. Make sure your script specified above takes that into account. Relevant if there is more than one selection set.
curve(c) boolean createquerymultiuse
Set curve selection mask on/off. (object flag)
curveKnot(ck) boolean createquerymultiuse
Set curve knot selection mask on/off. (component flag)
curveOnSurface(cos) boolean createquerymultiuse
Set curve-on-surface selection mask on/off. (object flag)
curveParameterPoint(cpp) boolean createquerymultiuse
Set curve parameter point selection mask on/off. (component flag)
dimension(dim) boolean createquerymultiuse
Set dimension shape selection mask on/off. (object flag)
dynamicConstraint(dc) boolean createquerymultiuse
Set dynamicConstraint selection mask on/off. (object flag)
edge(eg) boolean createquerymultiuse
Set mesh edge selection mask on/off. (component flag)
editPoint(ep) boolean createquerymultiuse
Set edit-point selection mask on/off. (component flag)
emitter(em) boolean createquerymultiuse
Set emitter selection mask on/off. (object flag)
enableRootSelection(ers) boolean createqueryedit
If set, the items to be selected are at their root transform level. Default is false.
escToQuit(esc) boolean createqueryedit
If set to true, exit the tool when press "Esc". Default is false.
exists(ex) boolean create
Returns true or false depending upon whether the specified object exists. Other flags are ignored.
exitUponCompletion(euc) boolean createqueryedit
If set, completing the last selection set will exit the tool. Default is true.
expandSelectionList(esl) boolean createqueryedit
If set, the selection lists will expand to have a single component in each item. You probably want this as a default, otherwise two isoparms on the same surface will show up as 1 item.

To ensure that components on the same object are returned in the order in which they are selected, use the selectPref -trackSelectionOrder on command in your -toolStart script to enable ordered selection, then restore it to its original value in your -toolFinish script.

facet(fc) boolean createquerymultiuse
Set mesh face selection mask on/off. (component flag)
field(fi) boolean createquerymultiuse
Set field selection mask on/off. (object flag)
finalCommandScript(fcs) script createqueryedit
Supply the script that will be run when the user presses the enter key and the context is completed. Depending on the number of selection sets you have, the script can make use of variables string $Selection1[], $Selection2[], ...
fluid(fl) boolean createquerymultiuse
Set fluid selection mask on/off. (object flag)
follicle(fo) boolean createquerymultiuse
Set follicle selection mask on/off. (object flag)
forceAddSelect(fas) boolean createqueryedit
If set to true, together with -setAutoToggleSelection (see below) on the first selection set, causes the first selection after the computation of the previous result to be "shift" selection, unless a modifier key is pressed. Default is false.

Flags for each selection set. These flags are multi-use.

hairSystem(hs) boolean createquerymultiuse
Set hairSystem selection mask on/off. (object flag)
handle(ha) boolean createquerymultiuse
Set object handle selection mask on/off. (object flag)
history(ch) boolean create
If this is a tool command, turn the construction history on for the tool in question.
hull(hl) boolean createquerymultiuse
Set hull selection mask on/off. (component flag)
ignoreInvalidItems(iii) boolean createqueryedit
If you have multiple selection sets, the state of the selection set is recorded at the time you "complete it". You could then delete some of the items in that list and end up with invalid items in one or more of your selection sets. If this flag is set, those items will be detected and ignored. You will never know it happened. Its as if they were never selected in the first place, except that your selection set now does not have as many items as it may need. If this flag is not set, you will get a warning and your final command callback script will likely not execute because of an error condition.
ikEndEffector(iee) boolean createquerymultiuse
Set ik end effector selection mask on/off. (object flag)
ikHandle(ikh) boolean createquerymultiuse
Set ik handle selection mask on/off. (object flag)
image1(i1) string createqueryedit
First of three possible icons representing the tool associated with the context.
image2(i2) string createqueryedit
Second of three possible icons representing the tool associated with the context.
image3(i3) string createqueryedit
Third of three possible icons representing the tool associated with the context.
imagePlane(ip) boolean createquerymultiuse
Set image plane selection mask on/off. (component flag)
implicitGeometry(ig) boolean createquerymultiuse
Set implicit geometry selection mask on/off. (object flag)
isoparm(iso) boolean createquerymultiuse
Set surface iso-parm selection mask on/off. (component flag)
joint(j) boolean createquerymultiuse
Set ik handle selection mask on/off. (object flag)
jointPivot(jp) boolean createquerymultiuse
Set joint pivot selection mask on/off. (component flag)
lastAutoComplete(lac) boolean createqueryedit
True if auto complete is set for the last selection set, false otherwise. Mostly used for query, but if present in conjuction with -sac/setAutoComplete flag, -sac flag takes precedence.
lattice(la) boolean createquerymultiuse
Set lattice selection mask on/off. (object flag)
latticePoint(lp) boolean createquerymultiuse
Set lattice point selection mask on/off. (component flag)
light(lt) boolean createquerymultiuse
Set light selection mask on/off. (object flag)
localRotationAxis(ra) boolean createquerymultiuse
Set local rotation axis selection mask on/off. (component flag)
locator(lc) boolean createquerymultiuse
Set locator (all types) selection mask on/off. (object flag)
locatorUV(luv) boolean createquerymultiuse
Set uv locator selection mask on/off. (object flag)
locatorXYZ(xyz) boolean createquerymultiuse
Set xyz locator selection mask on/off. (object flag)
nCloth(ncl) boolean createquerymultiuse
Set nCloth selection mask on/off. (object flag)
nParticle(npr) boolean createquerymultiuse
Set nParticle point selection mask on/off. (component flag)
nParticleShape(nps) boolean createquerymultiuse
Set nParticle shape selection mask on/off. (object flag)
nRigid(nr) boolean createquerymultiuse
Set nRigid selection mask on/off. (object flag)
name(n) string create
If this is a tool command, name the tool appropriately.
nonlinear(nl) boolean createquerymultiuse
Set nonlinear selection mask on/off. (object flag)
nurbsCurve(nc) boolean createquerymultiuse
Set nurbs-curve selection mask on/off. (object flag)
nurbsSurface(ns) boolean createquerymultiuse
Set nurbs-surface selection mask on/off. (object flag)
objectComponent(ocm) boolean createquery
Component flags apply to object mode.
orientationLocator(ol) boolean createquerymultiuse
Set orientation locator selection mask on/off. (object flag)
particle(pr) boolean createquerymultiuse
Set particle point selection mask on/off. (component flag)
particleShape(ps) boolean createquerymultiuse
Set particle shape selection mask on/off. (object flag)
plane(pl) boolean createquerymultiuse
Set sketch plane selection mask on/off. (object flag)
polymesh(p) boolean createquerymultiuse
Set poly-mesh selection mask on/off. (object flag)
polymeshEdge(pe) boolean createquerymultiuse
Set poly-mesh edge selection mask on/off. (component flag)
polymeshFace(pf) boolean createquerymultiuse
Set poly-mesh face selection mask on/off. (component flag)
polymeshFreeEdge(pfe) boolean createquerymultiuse
Set poly-mesh free-edge selection mask on/off. (component flag)
polymeshUV(puv) boolean createquerymultiuse
Set poly-mesh UV point selection mask on/off. (component flag)
polymeshVertex(pv) boolean createquerymultiuse
Set poly-mesh vertex selection mask on/off. (component flag)
polymeshVtxFace(pvf) boolean createquerymultiuse
Set poly-mesh vertexFace selection mask on/off. (component flag)
rigidBody(rb) boolean createquerymultiuse
Set rigid body selection mask on/off. (object flag)
rigidConstraint(rc) boolean createquerymultiuse
Set rigid constraint selection mask on/off. (object flag)
rotatePivot(rp) boolean createquerymultiuse
Set rotate pivot selection mask on/off. (component flag)
scalePivot(sp) boolean createquerymultiuse
Set scale pivot selection mask on/off. (component flag)
sculpt(sc) boolean createquerymultiuse
Set sculpt selection mask on/off. (object flag)
selectHandle(sh) boolean createquerymultiuse
Set select handle selection mask on/off. (component flag)
setAllowExcessCount(sae) boolean createeditmultiuse
If set, the number if items is to be interpreted as the minimum.
setAutoComplete(sac) boolean createeditmultiuse
If set to true, as soon as the specified number of items is selected the tool will start the next selection set or run the command.
setAutoToggleSelection(sat) boolean createeditmultiuse
If set to true, it is as if "shift" key is pressed when there are no modifiers pressed. That means that you get the "toggle select" behaviour by default. This only applies to the 3D view, and the selection done in the hypergraph, outliner or elsewhere is still a subject to the usual rules.
setDoneSelectionPrompt(dsp) string createeditmultiuse
If setAutoComplete is not set (see below) this string will be shown as soon as the tool has enough items for a particular selection set. If this is not set, but is needed, the same string as set with -setSelectionPrompt flag will be used.
setNoSelectionHeadsUp(snh) string createeditmultiuse
Supply a string that will be shown as a heads up prompt when there is nothing selected. This must be set separately for each selection set.
setNoSelectionPrompt(snp) string createeditmultiuse
Supply a string that will be shown as help when there is nothing selected. This must be set separately for each selection set.
setSelectionCount(ssc) int createeditmultiuse
The number of items in this selection set. 0 means as many as you need until completion.
setSelectionHeadsUp(ssh) string createeditmultiuse
Supply a string that will be shown as a heads up prompt when there is something selected. This must be set separately for each selection set.
setSelectionPrompt(ssp) string createeditmultiuse
Supply a string that will be shown as help when there is something selected. This must be set separately for each selection set.
showManipulators(sm) boolean createqueryedit
If set, the manipulators will be shown for any active objects. Basically, it is as if you are in the Show Manipulator tool.
spring(spr) boolean createquerymultiuse
Set spring shape selection mask on/off. (object flag)
springComponent(spc) boolean createquerymultiuse
Set individual spring selection mask on/off. (component flag)
stroke(str) boolean createquerymultiuse
Set the Paint Effects stroke selection mask on/off. (object flag)
subdiv(sd) boolean createquerymultiuse
Set subdivision surfaces selection mask on/off. (object flag)
subdivMeshEdge(sme) boolean createquerymultiuse
Set subdivision surfaces mesh edge selection mask on/off. (component flag)
subdivMeshFace(smf) boolean createquerymultiuse
Set subdivision surfaces mesh face selection mask on/off. (component flag)
subdivMeshPoint(smp) boolean createquerymultiuse
Set subdivision surfaces mesh point selection mask on/off. (component flag)
subdivMeshUV(smu) boolean createquerymultiuse
Set subdivision surfaces mesh UV map selection mask on/off. (component flag)
surfaceEdge(se) boolean createquerymultiuse
Set surface edge selection mask on/off. (component flag)
surfaceFace(sf) boolean createquerymultiuse
Set surface face selection mask on/off. (component flag)
surfaceKnot(sk) boolean createquerymultiuse
Set surface knot selection mask on/off. (component flag)
surfaceParameterPoint(spp) boolean createquerymultiuse
Set surface parameter point selection mask on/off. (component flag)
surfaceRange(sr) boolean createquerymultiuse
Set surface range selection mask on/off. (component flag)
surfaceUV(suv) boolean createquerymultiuse
Set surface uv selection mask on/off. (component flag)
texture(tx) boolean createquerymultiuse
Set texture selection mask on/off. (object flag)
title(t) string createqueryedit
Supply a string that will be used as a precursor to all the messages; i.e., the "name" of the tool.
toolCursorType(tct) string createqueryedit
Supply the string identifier to set the tool cursor type when inside of tool. The following are the valid ids: "create", "dolly", "edit", "pencil", "track", "trackHorizontal", "trackVertical", "transformation", "tumble", "zoom", "zoomIn", "zoomOut", "flyThrough", "dot", "fleur", "leftArrow", "question", "doubleHorizArrow", "doubleVertArrow", "sizing", "dollyIn", "dollyOut", "brush", "camera", "noAccess", "input", "output", "leftCycle", "rightCycle", "rightExpand", "knife".
toolFinish(tf) script createqueryedit
Supply the script that will be run when the user exits the script.
toolStart(ts) script createqueryedit
Supply the script that will be run when the user first enters the script
totalSelectionSets(tss) int createqueryedit
Total number of selection sets.
vertex(v) boolean createquerymultiuse
Set mesh vertex selection mask on/off. (component flag)

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Simple example of "attach curve" tool created using scriptCtx. This tool
# prompts the user to select two curves to attach. As soon as two curves
# are selected, the attach is performed. It uses the selection type
# flag 'curveParameterPoint' from "selectType" command to specify the
# selection mask for this tool.

cmds.scriptCtx( title='Attach Curve', totalSelectionSets=1, fcs="select -r $Selection1; performAttachCrv 0 \"\"", cumulativeLists=True, expandSelectionList=True, setNoSelectionPrompt='Select two curves close to the attachment points', setSelectionPrompt='Select a second curve close to the attachment point', setDoneSelectionPrompt='Never used because setAutoComplete is set', setAutoToggleSelection=True, setSelectionCount=2, setAutoComplete=True, curveParameterPoint=True )

# And a more complex example of fillet blend tool (two sets of any number
# of "surface curves").  Notice how the selection lists are passed as
# arguments to the callback function, performBlendGiven.

cmds.scriptCtx( i1='birail3Gen.xpm', title='"Birail 3+ Tool', toolCursorType='edit', totalSelectionSets=2, cumulativeLists=True, expandSelectionList=True, fcs='select -r $Selection2; performBirail 0 3 \"birailThreePlusProfileContext\" ', setAutoToggleSelection=[True,True], setAutoComplete=[False, False], setSelectionCount=[0,2], nurbsCurve=[True,True], isoparm=[True,True], curveOnSurface=[True,True], surfaceEdge=[True,True], polymeshEdge=[True,True], setNoSelectionPrompt=['Select any number of profiles','Select two rails'], setSelectionPrompt=['Select additional profiles or hit ENTER', 'Select the second rail'], setDoneSelectionPrompt=['Profiles selected. Hit ENTER to start rail selection.', 'Rails selected. Hit ENTER to compute birail. '] )

# Here's Birail 3+ where you select any number of curves, then 2 rails:

cmds.scriptCtx( i1='birail3Gen.xpm', title='"Birail 3+ Tool', toolCursorType='edit', totalSelectionSets=2, cumulativeLists=True, expandSelectionList=True, fcs='select -r $Selection2; performBirail 0 3 \"birailThreePlusProfileContext\" ', setAutoToggleSelection=[True,True], setAutoComplete=[False, False], setSelectionCount=[0,2], nurbsCurve=[True,True], isoparm=[True,True], curveOnSurface=[True,True], surfaceEdge=[True,True], polymeshEdge=[True,True], setNoSelectionPrompt=['Select any number of profiles','Select two rails'], setSelectionPrompt=['Select additional profiles or hit ENTER', 'Select the second rail'], setDoneSelectionPrompt=['Profiles selected. Hit ENTER to start rail selection.', 'Rails selected. Hit ENTER to compute birail. '] )

# userBirailContextCallback has "true" as the first argument, which suggests
# that $Selection2 contains all of $Selection1 items (as -cumulativeLists
# true is specified in the tool creation.)