PDA

View Full Version : create ImagePlanes using Python


WouterGilsing
08-06-2012, 01:37 PM
Hello,

I’m trying to create an ImagePlane by using Python (preferably Pymel).

The only thing I could find about it was this:
http://download.autodesk.com/glo...ndsPython/imagePlane.html (http://download.autodesk.com/global/docs/maya2013/en_us/CommandsPython/imagePlane.html)

but the example given at the end of the page didn’t work…

THis is the code:

import maya.cmds as cmds

# query whether the image plane on the persp camera
# is using a QuickTime movie
cmds.imagePlane( ‘persp’, q=True, qt=True )
# get the current timecode
cmds.imagePlane( ‘persp’, q=True, tc=True )

It resulted in “# Error: AttributeError: ‘module’ object has no attribute ‘imagePlane’ # “

I’m using Maya 2012 (I've tested the code on either Mac and Windows)

zoharl
08-06-2012, 02:40 PM
You gave a link to 2013 doc, and probably this command wasn't available at 2012. But don't feel bad about it, I can't make it work in 2013 either:

cmds.imagePlane( 'persp', q=True, qt=True )
# Error: Invalid object or value:
# Traceback (most recent call last):
# File "<maya console>", line 1, in
# RuntimeError: Invalid object or value: #

Panupat
08-06-2012, 03:23 PM
Yea I don't think the command exists in Maya 2012. The way I would create image plane would be like this

import maya.mel as mel
import maya.cmds as cmds

//choose camera
cameraName = "sideShape";

// create a new image plane
imagePlaneName = cmds.createNode("imagePlane")

// assign the imagePlane to the camera
mel.eval( 'cameraImagePlaneUpdate "%s" "%s";' % (cameraName, imagePlaneName) )

// Connect the image to imagePlane
imagePlaneFile = "C:\\Path\\to\\image.jpg"
cmds.setAttr( "%s.imageName" % imagePlaneName, imagePlaneFile, type="string")


Maybe use list relatives to check whether the image plane exists.

The cameraImagePlaneUpdate (along with a few other imagePlane mel commands) are actually script files. They're located in C:\Program Files\Autodesk\Maya2012\scripts\others. I think using mel eval is the only way to call them.

djx
08-07-2012, 12:17 PM
Working here... 2013x64

cmds.imagePlane('camera', q=True, qt=True)
# Result: [False] #

I noticed this in the docs
Currently, most queries work only on 64 bit Windows systems.

David

zoharl
08-07-2012, 01:09 PM
People still use x32?

stooch
08-09-2012, 06:23 PM
from pymel.core import *;

imagePlane("render_CAM", q=1, qt=1);

zoharl
08-10-2012, 11:53 AM
# Error: Unable to parse command argument list. #
# Error:
# Traceback (most recent call last):
# File "<maya console>", line 1, in
# File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pymel\internal\factories.py", line 844, in newFuncWithReturnFunc
# res = beforeReturnFunc(*args, **kwargs)
# File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pymel\internal\pmcmds.py", line 140, in wrappedCmd
# raise pymel.core.general._objectError(obj)
# MayaNodeError: Maya Node does not exist: u'render_CAM' #

djx
08-11-2012, 06:28 AM
# MayaNodeError: Maya Node does not exist: u'render_CAM' #
Isn't it obvious?

David

zoharl
08-11-2012, 07:03 AM
Right, I was just making a blind test on 2013:

mc.imagePlane("persp", q=1, qt=1);
# Error: Invalid object or value:
# Traceback (most recent call last):
# File "<maya console>", line 1, in
# File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pymel\internal\factories.py", line 844, in newFuncWithReturnFunc
# res = beforeReturnFunc(*args, **kwargs)
# File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pymel\internal\pmcmds.py", line 134, in wrappedCmd
# res = new_cmd(*new_args, **new_kwargs)
# RuntimeError: Invalid object or value: #

djx
08-11-2012, 08:32 AM
That is the expected result if there is no imagePlane associated with persp.

David

zoharl
08-11-2012, 10:14 AM
Right, now it's working...
My excuse: I'm only testing the code on 2013, and I'm not even sure what we trying to do. :arteest:

WouterGilsing
08-11-2012, 10:36 AM
Well, thanks for the help so far everybody. The thing I try to accomplish is to create an ImagePlane and associate it with my camera ...

djx
08-11-2012, 01:01 PM
Hey Wouter, sorry we got off track, but I had assumed the answer that Panupat gave you had covered that. As for the other command you mentioned in your question, I dont think it is actually of much use to you. It is all about querying movie stuff and I would not recommend using movies in imagePlanes (other may make a case for it though, and I'd be interested to hear their views). It dragged on a bit because zoharl was insisting that the command did not work, and I tried to help him see that it did, though in hind-sight, I probably should have let it go after my first post.

Do you still need help with imagePlane creation? Any specifics?

David

WouterGilsing
08-11-2012, 02:34 PM
No problem at all! I just tried the method Panupat suggested, again, and it worked great this time (i've no idea what I did wrong the first time, but it works for now).

Many thanks

CGTalk Moderation
08-11-2012, 02:34 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.