Consider this:
import pymel.core as pm
sel = pm.ls(sl=True)[0].getPosition() # Vertex selection
p = pm.datatypes.Point(sel)
print("p is %s and is of type %s")%(p, type(p))
someSet = pm.sets(p)
Results in:
p is [1.01064309961e-15, 1.14932883277, -1.0] and is of type <class ‘pymel.core.datatypes.Point’>
TypeError: Object 1.01064309961e-15 is invalid
Am I missing something here? Isn’t points considered to be an object that can be stored in a set???
You are attempting to put a Point, which is just a datatype, into a Maya set. As given here in the docs:
A set is a logical grouping of an arbitrary collection of objects, attributes, or components of objects.
If you want your sets to contain only vertices/edit points/cvs or other point-like objects, you need to make sure your argument is of one those types and not a pymel datatype like Point etc.
So in your case, instead of .getPosition, you’d just get the selected object as it is.
import pymel.core as pm
sel = pm.ls(sl=True)[0] # Vertex selection
print("p is %s and is of type %s")%(sel, type(sel))
someSet = pm.sets(sel)
Testing this with a few “point-like” objects I get:
sel is rightnurbsSquareShape1.ep[1] and is of type <class 'pymel.core.general.NurbsCurveEP'>
sel is pCubeShape1.vtx[2] and is of type <class 'pymel.core.general.MeshVertex'>
If you want to enforce a restriction on your set to include only point-like objects, you can set vertices flag while you create the set. Like so:
someSet = pm.sets(sel, vertices=True)
Hope this was useful.
[QUOTE=kartikg3;26147]You are attempting to put a Point, which is just a datatype, into a Maya set. As given here in the docs:
If you want your sets to contain only vertices/edit points/cvs or other point-like objects, you need to make sure your argument is of one those types and not a pymel datatype like Point etc.
So in your case, instead of .getPosition, you’d just get the selected object as it is.
import pymel.core as pm
sel = pm.ls(sl=True)[0] # Vertex selection
print("p is %s and is of type %s")%(sel, type(sel))
someSet = pm.sets(sel)
Testing this with a few “point-like” objects I get:
sel is rightnurbsSquareShape1.ep[1] and is of type <class 'pymel.core.general.NurbsCurveEP'>
sel is pCubeShape1.vtx[2] and is of type <class 'pymel.core.general.MeshVertex'>
If you want to enforce a restriction on your set to include only point-like objects, you can set vertices flag while you create the set. Like so:
someSet = pm.sets(sel, vertices=True)
Hope this was useful.[/QUOTE]
Alright, I see.
Thanks a bunch!