In maya the copy paste feature can be really useful. The major downside however is that every node that gets pasted gets a nice:
PASTED_ prefix attached to it. Resulting in a horribly messy scene that no one ever cares to clean up… until you have to revisit the scene and have to dive into the world of pasted_ nodes trying to find the correct shader etc.
Now there is a really easy fix for it:
In your maya instalation directory there is a file called cutCopyPaste.mel (of course thanks autodesk … )
in that is a function called pasteScene()
replace that function with the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
globalproc pasteScene(){
string$fileExt=".mb";
if(`about-ltVersion`){
$fileExt=".mlt";
}
elseif(`about-evalVersion`){
$fileExt=".mp";
}
// determine temp directory
string$tmpFile="/maya_sceneClipBoard"+$fileExt;
string$tmpdir=`getenv TMPDIR`;
string$filePath=($tmpdir+$tmpFile);
// import scene
string$newTransforms[]=`file-force
-import
-renameAll false
-mergeNamespacesOnClash true
-namespace":"
-groupReference
-returnNewNodes
$filePath`;
select-replace$newTransforms;
select-replace`ls-sl-head1`;
}
This will merge all the pasted nodes directly into the scene (root namespace ) without adding any prefix or suffix. (Only when the node all ready exists in the same depth it will add a number to the end).
Root Namespace
Whenever I loaded in a referenced scene maya would create a namespace (either with an normal namespace or it would prefix the nodes with the filename and an underscore). However Autodesk has finally been nice enough to open the functionality in the UI to load a scene into the root namespace (making sure the referenced scene does not get any weird naming or namespace. Making it easier to work with)
When going to File > Create reference
The trick is not to disable namespaces on load but enabling them and selecting the : ( root ) namespace and set the following option:
I had several people ask me this and usually I say. Install PyQt … on every machine that needs it and voilla. However this can not always be done and if you want to share your tools online then you just want your tools to work out of the box.
*Now a days I’d say just use pyside. No need for custom PyQt instalations anymore.
So hereby a short tutorial on how to build a QT interface with Designer that work in Maya. Since maya 2012 QT Designer is shipped with the installation of maya. You can find it here “C:\Program Files\Autodesk\<maya version>\bin\designer.exe”. This opens QT designer default interface and you can start creating your own UI’s with simple drag and drop actions. I will not go in depth on how to actually use QT designer in itself as I’ll leave that for a later time.
There are a few standard QT widgets(buttons, sliders etc) that Maya recognizes. As soon as you load the UI in maya, maya will detect these and will replace the widgets with maya’s own version. This means that you can edit, query and delete most of these detectable widgets just by using maya mel or python or pymel. No need for pyqt (even though that does make it a 100 times easier).
Someone on the creative crash website wrote a great introduction to using the QT interface. http://www.creativecrash.com/tutorials/using-qt-designer-for-mel-interfaces Especially the list of controls is very useful to keep handy when you are getting started with QT. Now I will try to skip most of the things that are covered there but some stuff might overlap.
1) Giving commands to button:
In QT Designer you can add a Dynamic Property that gets called every time the button is clicked. You can do this by going into the properties , click the plus icon and click “other… ”
Then in the “Create Dynamic Property” window, write “-c” without the quotes in the property name section. “-c” resembles the maya mel command for a button. You can add almost all commands like this. But most of the time you will only need “-c” or “-cc” for sliders etc. (*Note if you want to use python commands use a + instead of – )
Now in your property list you will see a new dynamic property at the end of the list. Here you can type any Maya Mel !!! command. However make sure its encapsulated in a string like this.
As you can see the command in itself needs to be in a string. This might cause some confusion as you will have to “escape” any other quotation marks by using a \. Do a search on escaping strings and you will find loads of information on this. As for python code just encapsulate it in a
1
"python(\" your python code goes here\")"
command.
or use a +c instead of -c.
If you have multiple lines of python code you want to put in one line use the always dreaded and nightmarish ; (semi colon).
They still give me nightmares from the time I was using mel. haha
3) Getting values from widgets that are not supported by maya.
Now lets do something that we are not supposed to. Now this is where it starts to get interesting for me. Every time I tried to use QT I always ran into this problem. HOW THE HECK DO YOU GET A VALUE FROM A SPINBOX or a DIAL or any other cool custom downloaded widget etc. It always bugged the hell out of me for not being able to find a stable way. But now I seem to have found a solution and the answer is “signals and hidden line edits”.
You can connect any widget to a line edit. To do this create a “line edit” anywhere in the UI. Preferably where it does not edit your layout but you can easily access it.
Go into “Edit Signal / Slots” Mode (F4) and click and drag from your widget to the “line edit”. This opens up a new window that allows you to link a value to the text field (providing the widget support exporting a Qstring)
Now on change of the original widget (a double spin box in this case) the “line edit ” in itself will be updated with the value. However if the user does not change the value the line edit will be empty. Which is why its a good idea to give it the same default value as the widget.
4) interacting with the UI from within maya WITHOUT USING PYQT.
So now when we load our QT Ui inside of maya we can query the text of our line edit every time we want to by using the following line of code:
A while ago I tried to deform one geometrical object with another. The source object would deform by using the blend shapes and the target object should deform accordingly. Unfortunately as soon as I would activate the blendshape the target mesh completely exploded.
After a while I figured out that Maya doesn’t like small faces very much an creates floating point errors in the calculation. Seeing as I dint have any access to the code with the Maya api I decided to look for a simple workaround.
Simply up scaling the model solved the problem. But as long as you either have a lamina face or a face that has a surface of a decimal number the geometry influence will explode.
After all these years I have finally found the time to set up a simple blog. I’ll use it to vent out all the small bugs and problems I run into. Hopefully so other people can find it and learn from it.