I can see the benefit of what you require, to add the functionality of deselecting everything after the frame selected command, just add the following line select -cl; as shown here : -
As for the other functionality required, should be fairly easy to get up and running, just need to add some conditional code based on having a current selection or not, if object is currently selected, Frame Selected, and if nothing is selected run rest of script.
Is there any way to stop Maya creating ".mayaSwatches" folders everywhere you make a project/file?
It seems incredibly unnecessary and is really cluttering up some of my folders.
Maya Help has nothing on this, I couldn't find it in the Preferences, and Googling for help on it doesn't find anything useful.
.mayaSwatches are created when Maya remembers / caches what your material icons are from the Hypershade. The swatches (material representations ) are loaded quicker when loading a scene back into Maya. Deleting the folder doesn't help much, as Maya instantly creates it when a scene is opened / saved each time. As far as I know, there's no current way of setting Maya not to do this, I just got used to deleting the relevant directory when zipping files and sending to people, or if I was in an asset management pipeline, I would check in the main files for instance - ignoring the swatches folder.
EDIT :
As far as I can tell from some quick tests, Export All may be a workaround if you can be bothered with that. I tried deleting the mayaSwatches folder, loading Maya from fresh and then utilising Export All rather than Save, seems to work without creating the mayaSwatches folder, although that would probably kill workflow anyway, I'm used to saving every few minutes anyway, unless you were to remap your save hotkeys with the Export All command instead, just a thought....
This time, it's about executing MEL scripts on startup. I have a bunch of MEL scripts in "My Documents/maya/scripts" (which the Maya Help tells me is one of the default directories for scripts).
These scripts have global procedures defined in them, but it doesn't seem like they're getting evaluated on startup. How can I make sure the procedures in these MEL files get activated every time I start Maya? Do I need to put them in a different folder, or define them in a special way? They work fine once I "source" them using the MEL window in Maya, but I want them to just work on startup, since I have hotkeys bound to the procs, but it keeps telling me the procedure doesn't exist when I try to use them after restarting Maya.
Ah, so every MEL file I want it to auto-load should be called in the userSetup.mel ?
I would have thought it'd just automatically grab all scripts at startup (something like Max's "scripts/startup" folder, which seems like an easier way to do it than having to keep a separate .mel file up to date).
Also, is it necessary to have the procedurename in the userSetup? I would have thought that just the source command would be enough.
Edit: Fixed the problem of them not loading on startup, one of my "source whatever.mel" lines had a typo in the file name ... which apparently breaks EVERYTHING in the userSetup.mel rather than just that line
Just put the source command right into the hotkey command itself. It won't slow sown normal operation of the hotkey (firt press might be slightly slower) & makes Maya load faster.
Replies
Glad it's working for you.
I can see the benefit of what you require, to add the functionality of deselecting everything after the frame selected command, just add the following line select -cl; as shown here : -
<font class="small">Code:</font><hr /><pre>
string $visibleObjects[];
clear $visibleObjects;
for ($layer in ` ls -typ "displayLayer"`)
{
if (` getAttr ($layer + ".v")` == 0)
$visibleObjects = stringArrayCatenate($visibleObjects, ` editDisplayLayerMembers -q $layer`);
}
select -r $visibleObjects;
select -tgl -ado;
FrameSelected;
select -cl;
</pre><hr />
As for the other functionality required, should be fairly easy to get up and running, just need to add some conditional code based on having a current selection or not, if object is currently selected, Frame Selected, and if nothing is selected run rest of script.
Added the extra functionality you were after : -
<font class="small">Code:</font><hr /><pre>
proc frameSelectedProc()
{
string $AnyObjects[]= `ls -sl -l`;
if(size($AnyObjects)!=0)
{
FrameSelected;
}
else
{
string $visibleObjects[];
clear $visibleObjects;
for ($layer in ` ls -typ "displayLayer"`)
{
if (` getAttr ($layer + ".v")` == 0)
$visibleObjects = stringArrayCatenate($visibleObjects, ` editDisplayLayerMembers -q $layer`);
}
select -r $visibleObjects;
select -tgl -ado;
FrameSelected;
select -cl;
}
}
frameSelectedProc;
</pre><hr />
Just copy to script editor, select and middle mouse drag to your shelf, or whatever your requirements are, assiging to the Hotkey you mentioned, etc.
Is there any way to stop Maya creating ".mayaSwatches" folders everywhere you make a project/file?
It seems incredibly unnecessary and is really cluttering up some of my folders.
Maya Help has nothing on this, I couldn't find it in the Preferences, and Googling for help on it doesn't find anything useful.
.mayaSwatches are created when Maya remembers / caches what your material icons are from the Hypershade. The swatches (material representations ) are loaded quicker when loading a scene back into Maya. Deleting the folder doesn't help much, as Maya instantly creates it when a scene is opened / saved each time. As far as I know, there's no current way of setting Maya not to do this, I just got used to deleting the relevant directory when zipping files and sending to people, or if I was in an asset management pipeline, I would check in the main files for instance - ignoring the swatches folder.
EDIT :
As far as I can tell from some quick tests, Export All may be a workaround if you can be bothered with that. I tried deleting the mayaSwatches folder, loading Maya from fresh and then utilising Export All rather than Save, seems to work without creating the mayaSwatches folder, although that would probably kill workflow anyway, I'm used to saving every few minutes anyway, unless you were to remap your save hotkeys with the Export All command instead, just a thought....
This time, it's about executing MEL scripts on startup. I have a bunch of MEL scripts in "My Documents/maya/scripts" (which the Maya Help tells me is one of the default directories for scripts).
These scripts have global procedures defined in them, but it doesn't seem like they're getting evaluated on startup. How can I make sure the procedures in these MEL files get activated every time I start Maya? Do I need to put them in a different folder, or define them in a special way? They work fine once I "source" them using the MEL window in Maya, but I want them to just work on startup, since I have hotkeys bound to the procs, but it keeps telling me the procedure doesn't exist when I try to use them after restarting Maya.
include the following:
source "yourfilename.mel";
yourprocedurename ();
I would have thought it'd just automatically grab all scripts at startup (something like Max's "scripts/startup" folder, which seems like an easier way to do it than having to keep a separate .mel file up to date).
Also, is it necessary to have the procedurename in the userSetup? I would have thought that just the source command would be enough.
procedurenames can be left out, all it does is execute the script at startup. If it´s sourced, it will auto load once the command gets called in maya.