Hi Subbu -
Unfortunately, the PyNode classes (such as pm.nt.ParentConstraint) do not
contain all of the functionality of the corresponding commands (ie,
pm.parentConstraint or cmds.parentConstraint).  In particular, the initial
creation of the underlying MAYA node must often be done with the command
form.  In fact, the only way it is currently possible to trigger the
creation of the underlying maya node AND the pynode with the pynode
constructor is when the PyNode constructor is fed no non-keyword args  (such
as when you do nt.ParentConstraint(mo=1, w=1) ).  If you need to create the
underlying node in manner in which you feed in other node args, you'll have
to fall back on the command:

import pymel.core as pm
cube1 = pm.polyCube()[0]
cube2 = pm.polyCube()[0]
pCon = pm.parentConstraint(cube1, cube2, mo=1, w=1)

In general, my habit is often to use the commands to create, and the PyNode
class constructors to create PyNodes for already-existing maya nodes.  I
agree, though, that it would be nice to expand support for node creation in

- Paul

PS - Did you know it's also possible to do the selection of multiple objects
in a single step? ie,
select ('pCube1', 'pCube2')

On Wed, Apr 20, 2011 at 2:12 AM, Subbu <[email protected]> wrote:

> Hi,
>
> When am trying in Python, Its working as below:
> import maya.cmds as cmds
> pCon =cmds.parentConstraint('pCube1', 'pCube2', mo=1, w=1)
>
>
> but in PyMel, Both the following are not working
>
> import pymel.core.nodetypes as nt
> pCon =nt.ParentConstraint('pCube1', 'pCube2', mo=1, w=1)
> or
> pCon =nt.ParentConstraint( PyNode('pCube1'), PyNode('pCube2'), mo=1,
> w=1)
>
> "Error: Unable to determine pymel type for 'pCube1' " is coming
>
>
> In single line it is not possible in PyMel, But its working in 3 lines
> like this:
> import pymel.core.nodetypes as nt
> select ('pCube1', r=1)
> select ('pCube2', add=1)
> pCon =nt.ParentConstraint(mo=1, w=1)
>
> Any one has any idea, so that I can save 2 lines code in this case,
> Constraints are repetitive in my code
>
> Thanks in advance.
>
> Subbu
>
> --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to