Hey guys,
Since I was getting some feedback in the other thread, I thought I'd better move my questions into a new one to avoid clutter.
Question 1: With the Absolute/Relative type-in transform fields (far right of the Status Line by default), it doesn't display the values of the current selection. For example if I select a vertex and want to move it to a specific location, it helps to know the current location.
I've looked for scripts to do this and can't find any.
Ideally I want to avoid having to write a script myself, but I'm not afraid to do that as a last resort.
Should also work for any selection - eg. if I select an object, I'd like for it to display the current absolute location in the X Y Z type-in fields. Should also work for an individual vertex/edge/face, and average position if more than one vert/edge/face is selected.
Question 2: If I have a vert/edge/face selection, is there any way I can "preserve" that when going between various selection modes? In Max, if I have a vert selection then go into Edge mode, when I go back to Vertex mode, the other selection will still be available ... this is really handy and I'm kinda missing it in Maya, every time I deselect an object I have to re-select the element selection I had last time
Question 3: When converting selections (eg. get a face selection, convert to vertices), it keeps the original mode, which is really annoying - I'm still in Face mode but I now have a selection of vertices that I can't add to or subtract from, because I'm in Face mode, and switching modes loses the selection!
I can't believe this is desired functionality, is there some option I've missed or something I'm doing wrong?
Replies
Question1: Select Vertex and go to Window -> General Editor -> Component Editor. You can now input the values. What do you specifically need that for, there is probably another way around it if you just need it for modeling purposes (Exporting and stuff is another thing, i can imagine why it would be useful there)
Question2: Download that
www.fuchtelworld.de/content/files/mayashelf/maya_shelf.zip
(Thanks to Paul Kamma)
Extract it and copy xt_selectcp.mel into your maya/scripts folder. Type xt_selectcp.mel into the script editor and run it. Save the selected script to the shelf or bind to a hotkey.
If you have something selected and run the script it saves the selection. If u deselect and run it again, it loads the previously saved selection. Beware: Only works if you dont change the geometry (like add additional edges, change vertex order)
Regarding my Question 2, while that script works, it's a pretty awkward workflow... I'm used to not having to think about saving selections like that, and it's a bit of a waste of time having to manually load/save all the time.
Fuse, IxenonI, with regards to Question 3, no matter which marking menu / menu / hotkey I use, it always leaves me in the old selection mode, so I have to change from face mode to vertex mode then hit Undo to get back the converted selection. There doesn't seem to be any options that I can find to make it switch the selection mode along with converting the selection
The Maya guy at work here says that's how he's always worked around it too, and I remember having the same problem in Maya 6... is it just some option in the preferences I've missed? If it is, it's well hidden...
Just to clarify, did you try having your face selected... hold ctrl and rmb drag "To vertices"... Works just fine for everyone around the office here.. I got 2008, 8.5 and 8
Regarding Question 2, i think thats probably something you have to get used to if you dont find a 3rd party plugin, as maya imho only supports these quick selection sets. If you find something, let me know please.
As I did test drive it, even after the mesh has been altered (additional edgeloops were added), the saved set does remember original selection.
I've been reading up on MEL script today and think I'm fairly close to getting a simple script to show the component info for location/rotation/scale in the abs. transform fields.
I have a feeling if I work a lot with Maya I will have to learn a lot of scripting just to get the tools up to speed with what I'm used to. Hopefully by then I will have learned enough to make better scripts beyond that, but that's the stage I'm already at with MaxScript so it feels like a fairly big step back
If you're used to Max, it's hard to get any decent polygon workflow unless you overhaul your hotkeys and tools.
Regarding question 3, I made hotkeys ctrl+1-6 to this script-block to accomplish that exact thing.
(window->settings/prefs->hotkey editor->User->New)
<font class="small">Code:</font><hr /><pre> {
//Convert CompSel to Faces
string $cheese[] = `polyListComponentConversion -tf`;
select -r $cheese;
selectType -suv 0 -ep 0 -cv 0 -smp 0 -sme 0 -smf 1 -smu 0 -pv 0 -pe 0 -pf 1 -puv 0;
} </pre><hr /> And then for verts and edges, you'd just change the -tf to -tv, -te and change the allowed selectType flags. This will change the selection mask whenever you convert it with the hotkey. there are probably more robust ways, but it's worked for me.
Fortunately though, MEL is actually really easy. It's mostly just knowing where to look for the commands in the command reference. I don't know how it compares to Maxscript though. I've been meaning to make a save-selection script or plugin forever but I never have the time. I'm not certain how to even do it efficiently...
So, about move objects in absolute world, you have some Mel script commands..
then for move all your selection in absolute position :
<font class="small">Code:</font><hr /><pre>float $finalPosition[] = {350.0, 250.0, 350.0};
string $currentSelection [] = `ls -sl -l`;
xform -a -ws -t $finalPosition [0] $finalPosition [1] $finalPosition [2] $currentSelection;</pre><hr />
// Lesson //
$finalPosition[] ===> give your final position {X,Y,Z}
carefull, only number with 1.0 form don't use 1 only (don't use Integer but only Float)
ls -l -sl ===> get long name of current objects selected...
xform -a -ws -t ===> Translate object list in absolute position in current world space.
// lesson end //
But I don't know if you know launch some lines in script editor...
If you really need some tools, or some other explications, send me private message, and I'll send you my msn.
Reedit :
For obtain all your Selection list position :
<font class="small">Code:</font><hr /><pre>// Get position list start //
string $currentSelection [] = `ls -sl -l -fl`;
float $positionList[] = `xform -a -ws -q -t $currentSelection`;
int $index = 0;
for ($object in $currentSelection)
{
string $cmd = ("\n- " + $object) +
("\n\t X= " + $positionList[$index]) +
("\n\t Y= " + $positionList[$index + 1]) +
("\n\t Z= " + $positionList[$index + 2]);
print $cmd;
$index +=3;
}
// Get position list end //</pre><hr />
if you don't like presentation of the print, just tell me what do you prefer ^_^.
Mel synthax on Polycount suck! It kill all my tabulations, etc..
I edited your post to put "code" tags around the code blocks, I think that's better for tabulation.
Regarding the int/float thing, I guess it's possible to convert any int input into a float before using it as a value for a command?
In Maxscript you can just say "variable as float" and it will convert the value, I assume there's a similar thing in Maya that could be used to avoid the int/float issue.
In maya for convert a integer in float you can do :
float $a = 2 * 1.0
and $ a = 2.0 it's easy.
<font class="small">Code:</font><hr /><pre>
int $a = 5;
print ("float a= " + (float)$a/2 + " but int a= " + $a/2 );
</pre><hr />
thanks man!!
In 3dsmax if I'm making a lowpoly object around a highpoly mesh, I "freeze" the layer with the highpoly meshes in, and I have a hotkey set to toggle "show/hide frozen objects" - this means I can easily work on the lowpoly alone and then show all my highpoly meshes on a keypress rather than going away to click an icon or menu somewhere else.
Is there a way to set a similar thing up in Maya? Like if I have a layer in "Reference" or "Template" mode, can I toggle the display of those objects with a hotkey?
layerEditorLayerButtonVisibilityChange high;
i dunno how to make a hotkey of it
edit: ah its easy, in the hotkey editor make a new hotkey and stick the script into the command box, and assign your key. Its a limited fix having to name your layer a specific name, but it works
This also means that you can hotkey any mel script/command.
[/ QUOTE ]
Yep, I'm well aware of this, you can do the same in Max
I've already scripted a few things for context-sensitive hotkeys. I guess I'll have to start learning the more complex stuff too.
I looked into CPS but it does seem quite out of date and I dunno if it's a good idea installing really old scripts. Might break stuff...
It'd be great reference for me re-learning MEL as well.
I don't know if this is what you want, but I just did this one (need some fun )
Then for the Hotkeys, Maya stocks that in 2 or 3 files, I think that suck, then I have a "sama_PersonnalHotkey.mel" in my script directory. And I edit the userSetup.mel in same directory for source my file and it launch it every maya launch...
For exemple in this Personnal hotkey file, a template line look like at this form:
<font class="small">Code:</font><hr /><pre>
//
Freeze Selection
//
nameCommand
-annotation "samavan_FreezeSelection"
-command "source \"Sama_Tools/samavan_FreezeSelection.mel\"; samavan_FreezeSelection ();"
samavan_FreezeSelectionNameCommand;
hotkey -k "$" -alt -ctl -name "samavan_FreezeSelectionNameCommand";
</pre><hr />
-annotation is the hotkey name,
-command is the code's lines,
-k "$" -alt -ctl is the hotkey (you can delete -alt for exemple or change the "$" for other key)
-name is something like (your hotkey name + "NameCommand")
Then with that you can create one file only with all your hotkeys... It more easy and usefull than 3 fucking files (thanks alias...).
For exemple in 3dsmax you have only one *.kbd file and enjoy!! ^_^
============================================================
Now, about your "freeze selection with layer" :
<font class="small">Code:</font><hr /><pre>
- What does the script?
- Create a layer with "freezeLayer" name.
- If already exist nothing is created.
- The current selection is added to the layer.
- Switch template mode value 0 to 2 each key is actived (and do a print evrytime you swith mode)
\\ Freeze Mode = 0;
\\ Freeze Mode = 2;
- How to stop everything?
- Do right click on "freezeLayer" and choose "Delete Layer" in the menu
- How to remove an object from layer?
- Just select the object when template mode value is 0 (or you can't select your object...)
- Do right click on "freezeLayer" and choose "Remove Selected Objects" in the menu.
</pre><hr />
You can download the script on this link.
I don't know your knowledge with Maya then I prefer to give you this informations :
- for install the script, copy&paste this 2 lines in your button or in your Hotkey command line:
source "samavan_FreezeSelection.mel"
samavan_FreezeSelection ();
- Drop the script file in your "...\MyDocuments\maya\8.0\scripts\"
8.0 is your maya version... then for you I don't know
- Maya layer menu + shoutbox
If You like this script and wish another function with this one, don't hesitate
haha I guess this thread got me thinking too. I started working on a save selection script when I'm in class and such, but it's a really buggy and weak implementation at the moment... Nothing to share yet for that reason
Hope this isn't derailing the thread too much
Looks like a good start already, that's exactly how Max does it.
Question 1 - Measuring:
In Max I can just select any object and immediately see it's exact bounds or dimensions using the Measure tool. How can I do this in Maya?
I don't want to have to manually create locators at each furthest point for the default line measure tool to work...
Question 2 - Editing Triangulation:
In Max I can just go into "Turn Edges" mode, and flip any invisible edges to get the triangulation how I want it, while still leaving only quads visible and editable.
In Maya it seems like there is no way to do this - if you re-triangulate a quad (using flip triangle edge, or the split polygon tool), then delete the edge to make it invisible again, Maya just resets the triangulation to whatever it wants.
Can't I edit the triangulation and still leave only the quads visible? That's going to be a huge annoyance if I can't.
I don't want all my meshes to end up in triangles just because I want control over which way a quad is triangulated...
Question 3 - Lattice vertex position:
While the "component editor" shows absolute positions for selected vertices, it doesn't seem to do the same for lattices/deformers. I want to add a Lattice to a model and be able to stretch it to an absolute value (ie. select all the left lattice verts and set them to X = -128.0) to scale the object to fit an exact size.
However it seems like lattice vertex coordinates don't show up in the Component Editor at all. I guess I could use Grid Snap in this case, but for values not on the grid it'd be good to be able to type in the value (Max's transform type-ins work for any selection).
Basically, if you do a Convert Selection from, say, faces to verts, it leaves you in Face mode (why????!). So naturally I press the hotkey for "vertex mode", at which point it loses my selection I just converted, so I have to hit Undo to get it back again. Not ideal.
So after talking with katzeimsack a bit tonight, it turns out that if you use the right-click menu to go into "vertex mode" after converting a selection, it keeps your selection!
Uhh... so why isn't the hotkey action for vertex mode exactly the same as the right-click action for vertex mode?
Ridiculous.
Woot, back with more questions...
Question 1 - Measuring:
In Max I can just select any object and immediately see it's exact bounds or dimensions using the Measure tool. How can I do this in Maya?
I don't want to have to manually create locators at each furthest point for the default line measure tool to work...
[/ QUOTE ]
Heya,
in the MEL command line thingy, type in polyEvaluate -fmt; for quick measurements.. what you're looking for is the bounding box...
something like this should print out:
// Result: vertex=400 edge=800 face=400 uvcoord=441 triangle=800 shell=1 vertexComponent=0 edgeComponent=0 faceComponent=0 uvComponent=0 triangleComponent=0 boundingBox= X[-8.76,10.98] Y[-2.00,1.95] Z[-6.45,13.29] boundingBoxComponent=none boundingBox2d= U[0.00,1.00] V[-0.00,1.00] boundingBoxComponent2d=none area=155.52 worldArea=606.22 //
I'm sure you can create a quick script that pops up a menu with this information.. if not I'll probably write one after class tonight because it is faster than using the measurement tool :]
If you can do a popup box like Max's one in the screenshot there (Dimensions X Y Z are all I'm really interested in, not surface area etc.), that'd be awesome!
I guess I might try it myself to learn some MEL script anyway...
Woot, back with more questions...
Question 2 - Editing Triangulation:
In Max I can just go into "Turn Edges" mode, and flip any invisible edges to get the triangulation how I want it, while still leaving only quads visible and editable.
In Maya it seems like there is no way to do this - if you re-triangulate a quad (using flip triangle edge, or the split polygon tool), then delete the edge to make it invisible again, Maya just resets the triangulation to whatever it wants.
Can't I edit the triangulation and still leave only the quads visible? That's going to be a huge annoyance if I can't.
I don't want all my meshes to end up in triangles just because I want control over which way a quad is triangulated...
[/ QUOTE ]
I HATE THIS!!!!
hate it hate it hate it.....
i just hand edit triangulation on the final model by making cuts in the geometry in problem areas, the good thing is that this doesn't change your vert ordering...
i dont have any selection problems really cause i am using nex, coming from max i dont think i could use maya with out it.
I guess I'll just have to leave it till the very end before doing any of that stuff.
Do you have the Bonus Games Tools installed ?
Measuring - For generalised Bounding Box information, you can select
Bonus Tools > Modelling > Bounding Box Scale Window
See here : -
For more indepth - i.e. edge analysis, you can toggle on edge length, and then select one or more edges
Bonus Tools > Modelling > Toggle Edge Length HUD
See here : -
Triangulation - Maya's triangulation is viewport dependant, you can see this on more detailed objects when transforming the object within the viewport, triangulation will change as you rotate, etc , the only really reliable way to control triangulation is to actually place the edges physically within, no workaround for this, it's a job probably best left for last in your workflow, as you already mentioned.
I can only assume MAX's code accounts for this, and lets you display quads whilst also giving you the ability to turn edges, I'd be curious to see if the same 'turned' edges are preserved on export into a game engine, Maya's triangulation is a very close approximation of how the mesh will triangulate on export, and as said previously, the only real control is to manually add and turn edges as needs require.
Lattice Vertex Positions - Create a cluster of your vertex selection, then you can manually ( or via numeric input ) move it as many units as needs require, just delete history on the lattice to remove it.
Convert Selection - Don't use the hotkey to switch to vertex mode, choose your faces, then convert your selection to verts as needs be, then right click on your object with the mouse and select vertex, you'll still have your selection and be in vertex mode only. Hotkey assumes no selection and 'readies' you for 'new' vertex selection.
ie. will they break any files already created, or cause file exchange problems? I'm guessing no, but just want to make sure
With lattices, what do you mean by cluster? I'm still learning Maya so some of the terms are unfamiliar
With the hotkey/right-click menu thing, is there any way to assign the hotkey to the same command as the right click menu? I always want to preserve selections when switching modes, and I find I'm faster with hotkeys for most operations, with right-click menu for less common actions.
Ideally it'd save selections between modes even if you're not converting too!.
With regards to Max's triangulation, yes, what you see is what it will export. It's basically always a fully triangulated mesh, new quads/polys are auto-triangulated by Max but you can then go into Turn Edge mode and just flip them around, their positions will be saved while still leaving you with editable polygon and quad shapes. They even try and preserve the direction you've chosen if you do an operation like Cut on a face. Seems like the most sensible way to do it, to me.
Thanks for the help!
The Bonus Games Tools are available from the AREA website at Autodesk.Com, must be registered on the site to download them : -
http://area.autodesk.com/index.php/downloads_plugins/plugin_detail/bonus_tools_for_maya_2008_win32/
Heavily recommend them, there's a a bunch of very useful tools within the package.
To answer your other question, for the lattices, just select your chosen vertices, then select
CREATE DEFORMERS > CLUSTER
then you can move the selection as needs be, keep the selection as a cluster or delete it ( delete history on lattice only, not object unless you want to lose lattice ). Cluster is just a selection set with a handle. But quicker I find.
With the hotkey issue, I'll need to look into this, I need to do some mel digging, to see how the function is called, seems perfectly plausible though, I'll let you know if see anything. If I switch on Echo All Commands within the script editor, I usually get to see more in depth how maya calls each function, sometimes it buried deeper though, and needs a bit more research.
It's worth digging around highend3d.com also, mostly, I find a lot of great scripts that I can rejig to my own needs. Not tested these, but these may be worth a look : -
http://highend3d.com/maya/downloads/mel_scripts/interface_display/SelectionMasks-2835.html
http://highend3d.com/maya/downloads/mel_scripts/interface_display/recallSelectionUI-mel-1826.html
http://highend3d.com/maya/downloads/mel_scripts/interface_display/rcUndoSelection-3466.html
EDIT : -
Also, it's worth mentioning that rather than using CONVERT TO to switch between faces, edges, verts, uvs, etc, you can use the marking menu, which is much quicker, say for example you have some faces selected, press CTRL and RIGHT MOUSE over your selection, and then choose your desired selection conversion, i.e. verts, etc, move to edge's for instance and choose contained edges to select edges, etc. Might take some getting used to when you initially start using it though!
SHIFT + RIGHT MOUSE, give you access to some basic modelling functions also.
EDIT 2 : -
Looked at the MEL functions behind the right click vertex selection, the main command called is : -
doMenuComponentSelection("pCube1", "vertex");
You seem like your pretty much up on your scripting anyway, so it shouldn't be too much trouble to see what the currently selected object is called, as in MEL's 'ls -sl', command, and replace the pCube1 with the current selection, save the script and assign it to a hotkey, you literally probably only need a few of lines of code to pull this off. Or alternately, let me know how the CTRL + Right Mouse works out for you, I personally think that way is easier! Obviously the above script would require to be saved out for each selection type, i.e. setting to vertex, setting to faces, edges, etc
Thanks again for taking the time to post this information and links
How can I make it just zoom extents to the visible stuff if nothing is selected? Seems a bit pointless zooming to the extents of things you can't see...
Yeah, that's also been a pet peeve of mine with Maya for a long time, I get round it by switching to a top view, frame everything, physically drag a selection around all visible objects within the scene that aren't hidden in layers and then go back to my Perspective view and then Frame Selected.
I had a quick look at writing a basic script that would handle this and then be assigned to a hotkey, using the load selection ( ls ) Mel command.
string $objectList[] = `ls -o -v`;
select $objectList ;
this basically loads all objects, but should be based on visibility only, the script then select's 'that' selection, then I can frame selected ( avoiding frame all ). This doesn't work though because ls.... -v flag looks within the DAG nodes, not the viewport. I'll carry on looking though later tonight, I'm sure there'll be a way round it.
Edit:
As for the triangulation thing... that is quite annoying. Here's a little workaround though, that might be helpful. (this isn't close to a perfect solution, but if you're just pushing things around this might help)
Create a copy of your quad mesh, and copy the vertex positions to the copy using Mesh > Copy Mesh Attributes > Vertex positions. Keep that node in the construction history. The new copy can be triangulated or split in to triangles however you like, but you can still use the original to move vertecies around, as long as you don't add vertecies, using edge loop selects or whatever.
I got the trial of NEX today and I'm loving it so far. All the stuff that Maya should have had by default is now available to me!
That NEX thing is really cool, gotta try that.
Edit: One thing to keep in mind (unless you're already doing that) is that you don't have to wait for the marking menus to show up. Just klick and drag in the right direction. Speeds things up a bit.
Been struggling to get anything workable together, I came up with : -
string $objectList[] = `ls -o`;
select -visible $objectList ;
FrameSelected;
fitPanel -selected;
which works, but only with objects that are hidden via CTRL + H, the script stores a list of all objects within the scene, then it filters them by visibility, objects that are hidden are disregarded, then the resultant selection is framed.
However, this proves fruitless to your problem, because your working with layers, and the objects are not physically hidden, it's just the visibility for the layer that is switched off, what I need to figure out is how to script a way to
( a ) Select only layers that have visibility switched off
( b ) Select all objects within each 'hidden' layer
( c ) Now hide that selection with script that is compatible with 'actually' hiding the objects, regardless of visibility, i.e. CTRL + H or the Mel command HideSelectedObjects;
( d ) Perform the script above
( e ) Then unhide the previously hidden objects, with the MEL command ShowLastHidden; to set the layers back to normal
This can be scripted to run automatically via a shelf item or hotkey. I'll take a look, but can't promise much, as it's starting to get too cumbersome for my liking.
Thanks to 'unsmoothed' from cgtalk, who has helped me out with the layer code, I've come up with the following solution to your frame all ( and not objects hidden - via layer visibility ) objects.
Copy this to a shelf item or your scripts folder and either use the shelf item to execute or assign it to a hotkey, note, it won't work directly from the script editor for some reason, but works perfectly from the shelf in the tests I've done : -
Anyway : -
<font class="small">Code:</font><hr /><pre>
string $visibleObjects[];
clear $visibleObjects;
for ($layer in ` ls -typ "displayLayer"`) {
if (` getAttr ($layer + ".v")` == 1)
$visibleObjects = stringArrayCatenate($visibleObjects, ` editDisplayLayerMembers -q $layer`);
}
select -r $visibleObjects;
FrameSelected;
fitPanel -selected;
</pre><hr />
Hope this makes things easier for you, I can't take credit for the script though, I only added the last two lines to it!
It only selects the visible objects and then zooms to the extents of everything, including the objects in the hidden layer.
This seems very strange to me, since if I manually select the visible objects, and type "FrameSelected;" into the MEL command line, it correctly only zooms to the extents of the selected objects.
Your script looks like it selects the visible objects, and then does the frame selected command, which should work, yet it actually still frames everything, even though the hidden stuff is not selected (I checked the outliner, the hidden objects do not get selected by your script, which is correct).
Dunno what's up with that...
I'm sure that can be fixed in the script, but I'm really bad at MEL.
inadvertently that script was working fine for me everytime I ran it, yet when I boot up Maya this morning, not working!
Anyway, I've rejigged the code : -
<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;
</pre><hr />
All I've done here is I now select every object that is IN a layer which has it's visibility turned off, then I toggle the INVERSE of that selection, frame selected comes thereafter, this works for me everytime now, and I've tried quitting Maya and running the script again to double check it.
To install, just copy and paste the above code into your script editor, and then select it and middle mouse drag it to your chosen shelf, then run it.
Let me know how this works out for you ?
I guess I should start learning MEL to tweak this script a bit - I want to set it up so that if you already have a selection, it only does the "FrameSelected;" command (so that you can bind it to the "frame selected" hotkey and have it work in all situations)... also I want to set it up so that if you didn't have anything selected originally, it deselects everything after the framing command (that part should be easy even for me!).
I still find it really silly that it's even necessary to have to write a script to do this, any other app would only zoom to visible objects. Once again it's Maya's half-hearted implementation of something - it works half the time, but is useless the rest of the time until you manually fix it to make it work the way it would only have been sensible to in the first place. I still don't know who at the Maya dev team thought it was desired functionality to zoom out to invisible objects... needs a good slap around the chops
Great job!