pymel.core.nodetypes.ObjectSet

Inheritance diagram of ObjectSet

class ObjectSet(*args, **kwargs)

The ObjectSet class and SelectionSet class work together. Both classes have a very similar interface, the primary difference is that the ObjectSet class represents connections to an objectSet node, while the SelectionSet class is a generic set, akin to pythons built-in set.

create some sets:

>>> from pymel.core import *
>>> f=newFile(f=1) #start clean
>>>
>>> s = sets()  # create an empty set
>>> s.union( ls( type='camera') )  # add some cameras to it
>>> s.members()  
[nt.Camera(u'sideShape'), nt.Camera(u'frontShape'), nt.Camera(u'topShape'), nt.Camera(u'perspShape')]
>>> sel = s.asSelectionSet() # or as a SelectionSet
>>> sel 
nt.SelectionSet([u'sideShape', u'frontShape', u'topShape', u'perspShape'])
>>> sorted(sel) # as a sorted list
[nt.Camera(u'frontShape'), nt.Camera(u'perspShape'), nt.Camera(u'sideShape'), nt.Camera(u'topShape')]

Operations between sets result in SelectionSet objects:

>>> t = sets()  # create another set
>>> t.add( 'perspShape' )  # add the persp camera shape to it
>>> s.getIntersection(t)
nt.SelectionSet([u'perspShape'])
>>> diff = s.getDifference(t)
>>> diff 
nt.SelectionSet([u'sideShape', u'frontShape', u'topShape'])
>>> sorted(diff)
[nt.Camera(u'frontShape'), nt.Camera(u'sideShape'), nt.Camera(u'topShape')]
>>> s.isSuperSet(t)
True
Restriction = Enum( EnumValue('Restriction', 0, 'none'), EnumValue('Restriction', 1, 'verticesOnly'), EnumValue('Restriction', 2, 'edgesOnly'), EnumValue('Restriction', 3, 'facetsOnly'), EnumValue('Restriction', 4, 'editPointsOnly'), EnumValue('Restriction', 5, 'renderableOnly'))
add(item)
addMembers(list)

Add a list of new objects to the set.

Parameters :
list : SelectionSet

the list of objects as a selection list

Derived from api method maya.OpenMaya.MFnSet.addMembers

Undo is not currently supported for this method

asSelectionSet(flatten=False)

Get the members of this set as a selection list. This information is provided as a selection list so that all of the path information is retained for DAG nodes.

Parameters :
flatten : bool

whether to flatten the returned list.

Return type:

SelectionSet

Derived from api method maya.OpenMaya.MFnSet.getMembers

clear()

Removes all elements from this set Derived from api method maya.OpenMaya.MFnSet.clear

Undo is not currently supported for this method

difference(other)
elements(*args, **kwargs)

The function ‘pymel.core.nodetypes.ObjectSet.elements’ is deprecated and will become unavailable in future pymel versions. Use ObjectSet.members instead

return members as a list
rtype:list
flattened()

return a flattened list of members. equivalent to ObjectSet.members(flatten=True) :rtype: list

getAnnotation()

Returns the annotation string for this set. This allows a description of the set to be stored with it.

Return type:unicode

Derived from api method maya.OpenMaya.MFnSet.annotation

getDifference(other)
Return type:SelectionSet
getIntersection(other)
Return type:SelectionSet
getSymmetricDifference(other)

also known as XOR :rtype: SelectionSet

getUnion(other)
Return type:SelectionSet
hasRestrictions()

Returns true if this function set has restrictions on the type of objects that it may contain.

Return type:bool

Derived from api method maya.OpenMaya.MFnSet.hasRestrictions

intersection(other)
intersectsWith(otherSet)

Returns true if this set intersects with the given set. An intersection occurs if there are any common members between the two sets.

Parameters :
otherSet : PyNode

set to test for intersection with

Return type:

bool

Derived from api method maya.OpenMaya.MFnSet.intersectsWith

isEqual(other)

do not use __eq__ to test equality of set contents. __eq__ will only tell you if the passed object is the same node, not if this set and the passed set have the same contents. :rtype: bool

isRenderable()

Mimics cmds.sets(self, q=True, renderable=True).

Alternatively you can use isinstance(someset, pm.nt.ShadingEngine) since shadingEngine is the only renderable set in maya now

isSubSet(other)
Return type:bool
isSuperSet(other)
Return type:bool
members(flatten=False)

return members as a list :rtype: list

remove(item)
removeMembers(list)

Remove items of the selection list from the set.

Parameters :
list : SelectionSet

the selection list of items to remove

Derived from api method maya.OpenMaya.MFnSet.removeMembers

Undo is not currently supported for this method

resetTo(newContents)

clear and set the members to the passed list/set

restriction()

Returns the type of membership restriction that this set has.

Return type:ObjectSet.Restriction

Derived from api method maya.OpenMaya.MFnSet.restriction

setAnnotation(annotation)

Sets the annotation string for this set. This allows a description of the set to be stored with it.

Parameters :
annotation : unicode

new annotation string

Derived from api method maya.OpenMaya.MFnSet.setAnnotation

symmetricDifference(other)
union(other)

Previous topic

pymel.core.nodetypes.ObjectScriptFilter

Next topic

pymel.core.nodetypes.ObjectTypeFilter

Core

Core Modules

Other Modules

This Page