Litlle help in maya mel

my first post here so hello all.long time reader.

i need some help in a script or maybe some simple mel question.

i use a little toolbox(nmToolbox) that i drop icons there with the command.
here a example

ctxEditMode;snapMode -point true;

this turn activate change pivot, and snap to point in 1 click. fast way for me to snap fast the pivot to poit in 1 click.
the problem is that i needed another click in another icon with

ctxEditMode;snapMode -point false;

my question is can i combine both in just one icon someting like a press/release hotkey.

what i want is

click

ctxEditMode;snapMode -point true;

click again same icon

ctxEditMode;snapMode -point false;
.
any easy solution?

many thxs in advance.

hey mate try making a shelf button with this python code, and it should do the job for you.


import maya.cmds as cmds

if cmds.snapMode(q=True, point=True):
    cmds.ctxEditMode()
    cmds.snapMode(point=False)
else:
    cmds.ctxEditMode()
    cmds.snapMode(point=True)

also are you aware of the V and the d key shortcuts in maya, holding d lets you edit the object orgin, and holding v enables vertex snapping.

passerby many thanks for both tips, the script is exactly what i want now with python( “import sys;sys.version_info” ); it can go in my toolbox without problem.
the hotkey, they new for me, at least the d key i always used insert key, and not much produtivity. d and v is great . as i undestand the python code you givei can adapt to other commands .

many thxs again

best regards

ps:actualy i dont know how to use it with python( “import sys;sys.version_info” ); :wink: i used it in the past to use python in mel as nmToolbox cant use python , maybe i need to save the code you give me in script folder.
anyway i just need to get used to the hotkeys they great.

i only put it in python becuase that is the syntax and language i am most familar with, the exact same thing can be done via mel


if (`snapMode -q -point`)
{
    ctxEditMode;
    snapMode -point false;
}
else
{
    ctxEditMode;
    snapMode -point true;
}

this is just the basics of programming just a if else statement to create a simple toggle, works exactly the same way with just some syntax changes in pretty much every language known to man.

many thxs again as i use wacom tablet clicks are ok for me .

global proc pivotinsert()
{

if (snapMode -q -point)
{
ctxEditMode;
snapMode -point false;
}
else
{
ctxEditMode;
snapMode -point true;
}

}

i just made it a script ;p so i can use it in frotools(by froyok) too.
this code will help me a lot .

good night and glad you help

ya you should take some time to learn one of maya’s languages, since what i did was pretty simple just a “if else” statement than most maya commands got a -q argument for querying values instead of setting them.

ctxEditMode;
snapMode -point (!`snapMode -q -point`);