pymel.core.context.scriptCtx

scriptCtx(*args, **kwargs)

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 selectTypecommand can be used here.

Flags:

Long Name / Short Name Argument Types Properties
allComponents / alc bool ../../../_images/create.gif ../../../_images/query.gif
  Set all component selection masks on/off
allObjects / alo bool ../../../_images/create.gif ../../../_images/query.gif
  Set all object selection masks on/off
animBreakdown / abd bool ../../../_images/create.gif ../../../_images/query.gif
  Set animation breakdown selection mask on/off.
animCurve / ac bool ../../../_images/create.gif ../../../_images/query.gif
  Set animation curve selection mask on/off.
animInTangent / ait bool ../../../_images/create.gif ../../../_images/query.gif
  Set animation in-tangent selection mask on/off.
animKeyframe / ak bool ../../../_images/create.gif ../../../_images/query.gif
  Set animation keyframe selection mask on/off.
animOutTangent / aot bool ../../../_images/create.gif ../../../_images/query.gif
  Set animation out-tangent selection mask on/off.
baseClassName / bcn unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  This string will be used to produce MEL function names for the property sheets for the tool. For example, if myScriptToolwas given, the functions myScriptToolValuesand myScriptToolPropertieswill be used for the property sheets. The default is scriptTool.
byName / bn unicode, int  
   
camera / ca bool ../../../_images/create.gif ../../../_images/query.gif
  Set camera selection mask on/off. (object flag)
cluster / cl bool ../../../_images/create.gif ../../../_images/query.gif
  Set cluster selection mask on/off. (object flag)
collisionModel / clm bool ../../../_images/create.gif ../../../_images/query.gif
  Set collision model selection mask on/off. (object flag)
controlVertex / cv bool ../../../_images/create.gif ../../../_images/query.gif
  Set control vertex selection mask on/off. (component flag)
cumulativeLists / cls bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif
  Set curve selection mask on/off. (object flag)
curveKnot / ck bool ../../../_images/create.gif ../../../_images/query.gif
  Set curve knot selection mask on/off. (component flag)
curveOnSurface / cos bool ../../../_images/create.gif ../../../_images/query.gif
  Set curve-on-surface selection mask on/off. (object flag)
curveParameterPoint / cpp bool ../../../_images/create.gif ../../../_images/query.gif
  Set curve parameter point selection mask on/off. (component flag)
dimension / dim bool ../../../_images/create.gif ../../../_images/query.gif
  Set dimension shape selection mask on/off. (object flag)
dynamicConstraint / dc bool ../../../_images/create.gif ../../../_images/query.gif
  Set dynamicConstraint selection mask on/off. (object flag)
edge / eg bool ../../../_images/create.gif ../../../_images/query.gif
  Set mesh edge selection mask on/off. (component flag)
editPoint / ep bool ../../../_images/create.gif ../../../_images/query.gif
  Set edit-point selection mask on/off. (component flag)
emitter / em bool ../../../_images/create.gif ../../../_images/query.gif
  Set emitter selection mask on/off. (object flag)
enableRootSelection / ers bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  If set, the items to be selected are at their root transform level. Default is false.
escToQuit / esc bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  If set to true, exit the tool when press Esc. Default is false.
exists / ex bool ../../../_images/create.gif
  Returns true or false depending upon whether the specified object exists. Other flags are ignored.
exitUponCompletion / euc bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  If set, completing the last selection set will exit the tool. Default is true.
expandSelectionList / esl bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 oncommand in your -toolStartscript to enable ordered selection, then restore it to its original value in your -toolFinishscript.
facet / fc bool ../../../_images/create.gif ../../../_images/query.gif
  Set mesh face selection mask on/off. (component flag)
field / fi bool ../../../_images/create.gif ../../../_images/query.gif
  Set field selection mask on/off. (object flag)
finalCommandScript / fcs script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif
  Set fluid selection mask on/off. (object flag)
follicle / fo bool ../../../_images/create.gif ../../../_images/query.gif
  Set follicle selection mask on/off. (object flag)
forceAddSelect / fas bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 shiftselection, unless a modifier key is pressed. Default is false. Flags for each selection set. These flags are multi-use.
hairSystem / hs bool ../../../_images/create.gif ../../../_images/query.gif
  Set hairSystem selection mask on/off. (object flag)
handle / ha bool ../../../_images/create.gif ../../../_images/query.gif
  Set object handle selection mask on/off. (object flag)
history / ch bool ../../../_images/create.gif
  If this is a tool command, turn the construction history on for the tool in question.
hull / hl bool ../../../_images/create.gif ../../../_images/query.gif
  Set hull selection mask on/off. (component flag)
ignoreInvalidItems / iii bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif
  Set ik end effector selection mask on/off. (object flag)
ikHandle / ikh bool ../../../_images/create.gif ../../../_images/query.gif
  Set ik handle selection mask on/off. (object flag)
image1 / i1 unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  First of three possible icons representing the tool associated with the context.
image2 / i2 unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Second of three possible icons representing the tool associated with the context.
image3 / i3 unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Third of three possible icons representing the tool associated with the context.
imagePlane / ip bool ../../../_images/create.gif ../../../_images/query.gif
  Set image plane selection mask on/off. (component flag)
implicitGeometry / ig bool ../../../_images/create.gif ../../../_images/query.gif
  Set implicit geometry selection mask on/off. (object flag)
isoparm / iso bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface iso-parm selection mask on/off. (component flag)
joint / j bool ../../../_images/create.gif ../../../_images/query.gif
  Set ik handle selection mask on/off. (object flag)
jointPivot / jp bool ../../../_images/create.gif ../../../_images/query.gif
  Set joint pivot selection mask on/off. (component flag)
lastAutoComplete / lac bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif
  Set lattice selection mask on/off. (object flag)
latticePoint / lp bool ../../../_images/create.gif ../../../_images/query.gif
  Set lattice point selection mask on/off. (component flag)
light / lt bool ../../../_images/create.gif ../../../_images/query.gif
  Set light selection mask on/off. (object flag)
localRotationAxis / ra bool ../../../_images/create.gif ../../../_images/query.gif
  Set local rotation axis selection mask on/off. (component flag)
locator / lc bool ../../../_images/create.gif ../../../_images/query.gif
  Set locator (all types) selection mask on/off. (object flag)
locatorUV / luv bool ../../../_images/create.gif ../../../_images/query.gif
  Set uv locator selection mask on/off. (object flag)
locatorXYZ / xyz bool ../../../_images/create.gif ../../../_images/query.gif
  Set xyz locator selection mask on/off. (object flag)
meshComponents / mc bool  
   
meshUVShell / msh bool  
   
motionTrailPoint / mtp bool  
   
motionTrailTangent / mtt bool  
   
nCloth / ncl bool ../../../_images/create.gif ../../../_images/query.gif
  Set nCloth selection mask on/off. (object flag)
nParticle / npr bool ../../../_images/create.gif ../../../_images/query.gif
  Set nParticle point selection mask on/off. (component flag)
nParticleShape / nps bool ../../../_images/create.gif ../../../_images/query.gif
  Set nParticle shape selection mask on/off. (object flag)
nRigid / nr bool ../../../_images/create.gif ../../../_images/query.gif
  Set nRigid selection mask on/off. (object flag)
name / n unicode ../../../_images/create.gif
  If this is a tool command, name the tool appropriately.
nonlinear / nl bool ../../../_images/create.gif ../../../_images/query.gif
  Set nonlinear selection mask on/off. (object flag)
nurbsCurve / nc bool ../../../_images/create.gif ../../../_images/query.gif
  Set nurbs-curve selection mask on/off. (object flag)
nurbsSurface / ns bool ../../../_images/create.gif ../../../_images/query.gif
  Set nurbs-surface selection mask on/off. (object flag)
objectComponent / ocm bool ../../../_images/create.gif ../../../_images/query.gif
  Component flags apply to object mode.
orientationLocator / ol bool ../../../_images/create.gif ../../../_images/query.gif
  Set orientation locator selection mask on/off. (object flag)
particle / pr bool ../../../_images/create.gif ../../../_images/query.gif
  Set particle point selection mask on/off. (component flag)
particleShape / ps bool ../../../_images/create.gif ../../../_images/query.gif
  Set particle shape selection mask on/off. (object flag)
plane / pl bool ../../../_images/create.gif ../../../_images/query.gif
  Set sketch plane selection mask on/off. (object flag)
polymesh / p bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh selection mask on/off. (object flag)
polymeshEdge / pe bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh edge selection mask on/off. (component flag)
polymeshFace / pf bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh face selection mask on/off. (component flag)
polymeshFreeEdge / pfe bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh free-edge selection mask on/off. (component flag)
polymeshUV / puv bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh UV point selection mask on/off. (component flag)
polymeshVertex / pv bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh vertex selection mask on/off. (component flag)
polymeshVtxFace / pvf bool ../../../_images/create.gif ../../../_images/query.gif
  Set poly-mesh vertexFace selection mask on/off. (component flag)
queryByName / qbn unicode  
   
rigidBody / rb bool ../../../_images/create.gif ../../../_images/query.gif
  Set rigid body selection mask on/off. (object flag)
rigidConstraint / rc bool ../../../_images/create.gif ../../../_images/query.gif
  Set rigid constraint selection mask on/off. (object flag)
rotatePivot / rp bool ../../../_images/create.gif ../../../_images/query.gif
  Set rotate pivot selection mask on/off. (component flag)
scalePivot / sp bool ../../../_images/create.gif ../../../_images/query.gif
  Set scale pivot selection mask on/off. (component flag)
sculpt / sc bool ../../../_images/create.gif ../../../_images/query.gif
  Set sculpt selection mask on/off. (object flag)
selectHandle / sh bool ../../../_images/create.gif ../../../_images/query.gif
  Set select handle selection mask on/off. (component flag)
setAllowExcessCount / sae bool ../../../_images/create.gif ../../../_images/edit.gif
  If set, the number if items is to be interpreted as the minimum.
setAutoComplete / sac bool ../../../_images/create.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/edit.gif
  If set to true, it is as if shiftkey is pressed when there are no modifiers pressed. That means that you get the toggle selectbehaviour 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 unicode ../../../_images/create.gif ../../../_images/edit.gif
  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 unicode ../../../_images/create.gif ../../../_images/edit.gif
  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 unicode ../../../_images/create.gif ../../../_images/edit.gif
  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 ../../../_images/create.gif ../../../_images/edit.gif
  The number of items in this selection set. 0 means as many as you need until completion.
setSelectionHeadsUp / ssh unicode ../../../_images/create.gif ../../../_images/edit.gif
  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 unicode ../../../_images/create.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 bool ../../../_images/create.gif ../../../_images/query.gif
  Set spring shape selection mask on/off. (object flag)
springComponent / spc bool ../../../_images/create.gif ../../../_images/query.gif
  Set individual spring selection mask on/off. (component flag)
stroke / str bool ../../../_images/create.gif ../../../_images/query.gif
  Set the Paint Effects stroke selection mask on/off. (object flag)
subdiv / sd bool ../../../_images/create.gif ../../../_images/query.gif
  Set subdivision surfaces selection mask on/off. (object flag)
subdivMeshEdge / sme bool ../../../_images/create.gif ../../../_images/query.gif
  Set subdivision surfaces mesh edge selection mask on/off. (component flag)
subdivMeshFace / smf bool ../../../_images/create.gif ../../../_images/query.gif
  Set subdivision surfaces mesh face selection mask on/off. (component flag)
subdivMeshPoint / smp bool ../../../_images/create.gif ../../../_images/query.gif
  Set subdivision surfaces mesh point selection mask on/off. (component flag)
subdivMeshUV / smu bool ../../../_images/create.gif ../../../_images/query.gif
  Set subdivision surfaces mesh UV map selection mask on/off. (component flag)
surfaceEdge / se bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface edge selection mask on/off. (component flag)
surfaceFace / sf bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface face selection mask on/off. (component flag)
surfaceKnot / sk bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface knot selection mask on/off. (component flag)
surfaceParameterPoint / spp bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface parameter point selection mask on/off. (component flag)
surfaceRange / sr bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface range selection mask on/off. (component flag)
surfaceUV / suv bool ../../../_images/create.gif ../../../_images/query.gif
  Set surface uv selection mask on/off. (component flag)
texture / tx bool ../../../_images/create.gif ../../../_images/query.gif
  Set texture selection mask on/off. (object flag)
title / t unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Supply a string that will be used as a precursor to all the messages; i.e., the nameof the tool.
toolCursorType / tct unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  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 ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Supply the script that will be run when the user exits the script.
toolStart / ts script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Supply the script that will be run when the user first enters the script
totalSelectionSets / tss int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Total number of selection sets.
vertex / v bool ../../../_images/create.gif ../../../_images/query.gif
  Set mesh vertex selection mask on/off. (component flag) Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.scriptCtx

Example:

import pymel.core as pm

# 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.

pm.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 )
# Result: u'scriptCtx1' #

# 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.

pm.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. '] )
# Result: u'scriptCtx2' #

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

pm.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. '] )
# Result: u'scriptCtx3' #

# 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.)