View Full Version : [Python] Basics and more
07-12-2012, 09:36 AM
Right a little about my background in coding... I did some scripts in maxscript back in the day. I looked over maya in recent months and now I decided to easy my live with a bit of python for maya...
I run in to few issues - which I will post here as I go but as start I have a little problem getting to work creating Layer Ovverides in render settings. Its something I'd like to set up for easy scene set up... Here is my python start and error I get... any hints where I went wrong ?
import maya.cmds as cmds
import maya.mel as mel
cmds.setAttr ('defaultRenderGlobals.enableDefaultLight', 0);
cmds.setAttr ('miDefaultOptions.scanline', 0);
I get this error
# Error: line 1: No object matches name: 0
# Traceback (most recent call last):
# File "<maya console>", line 12, in
# ValueError: No object matches name: 0 #
// Result: scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|formLayout40|tabLayout2|formLayout65|cmdScrollFieldExecuter8 //
control -edit -enable true miMinSampleCtrl;
// Result: miMinSampleCtrl //
Now I was tring to change the 0 number at the end to 1/2 and erase it but I always get error :/
Any hints where I went wrong? :s
07-12-2012, 01:03 PM
Sorted I think I had miss spell or other issue... in any case...
This creates layer override in render settings.
I'm guessing by your use of the semicolon at the end of each line that you are copying and pasting the mel output from the script editor and converting it to python. You almost got it right.
Problem 1: Maya delays the creation of some nodes until they are needed. In this case 'miDefaultOptions' may not exist until you open the render-settings window and select the quality tab. (Actually its a while since I dabbled in mentalray so someone may wish to correct me here). You can create it like this:
if not cmds.objExists("miDefaultOptions"):
Problem 2: The syntax is incorrect for the editRenderLayerAdjustment command. It should be:
Or if you want to, you can specify the layer you are adding the adjustment for
I'd leave out the semi-colons too.
edit: Try and ignore the extra spaces that cgtalk loves to insert :shrug:
07-12-2012, 02:55 PM
somebody should punch cgtalks code formatting square in the n uts
07-12-2012, 04:16 PM
Thanks very much ! I got it to work at the end :]
I'm now working on getting a nice UI - wish maya had max alike UI editor hehe :] I got a headache from trying to find how to move buttons + create sliders to add controls to my render set up haha fun !
Will be most likely back soon with more little tiny issues hehe :)
07-17-2012, 08:22 PM
I got it roughtly where I wanted... the last think that wont let me sleep is to set up my AA filter to be custom... what is the darn command for it ?
I went over DefaultOptions and MentalRayOptions as well as render globals and I cant find it or im blind arr :/
07-17-2012, 08:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.