__builtin__ :: set :: Variable set :: Class ObjectSet
[hide private]
[frames] | no frames]

Class ObjectSet

source code

Extended and more convenient object set interface dealing with Nodes ( and provides the original MFnSet interface as well
Nested Classes [hide private]
  __metaclass__
Builds the base hierarchy for the given classname based on our typetree :todo: build classes with slots only as members are pretermined
    Set Operations
  _TmpSet
Temporary set that will delete itself once its python destructor is called
Instance Methods [hide private]
 
members(self, flatten=False)
Returns: MSelectionList with members of this set
source code
 
union(self, objects, sets_are_members=False)
Create a union of the given items with the members of this set
source code
 
intersection(self, objects, sets_are_members=False)
As union, but returns the intersection ( items in common ) of this set with objects
source code
 
difference(self, objects, sets_are_members=False)
return the result of self minus objects, thus objects will be substracted from our obejcts
source code
    Partition Handling
 
partitions(self)
Returns: list of Nodes of partitions the entity is set is part of
source code
 
setPartition(self, partition, mode=0)
Add, add exclusive or remove the given partition from our partition list
source code
    Member Editing
 
_toMemberObj(self, member)
Convert member to a valid member object ( MObject, DagPath or Plug )
source code
 
_forceMembership(self, member, component, is_single_member, ignore_failure)
Search all sets connected to our partitions for intersecting members and remove them.
source code
 
_checkMemberAddResult(self, member, component, mode, ignore_failure, is_single_member)
Check whether the given member has truly been added to our set and either force membership or raise and exception
source code
 
_addRemoveMember(self, member, component, mode, ignore_failure)
Add or remove the member with undo support
source code
 
_addRemoveMembers(self, members, mode, ignore_failure)
Add or remove the members to the set
source code
 
clear(self)
Clear the set so that it will be empty afterwards
source code
 
addMember(self, member, component=api.MObject(), force=False, ignore_failure=False)
Add the item to the set
source code
 
add(self, member_or_members, *args, **kwargs)
Combined method which takes single or multiple members which are to be added
source code
 
removeMember(self, member, component=api.MObject())
Remove the member from the set
source code
 
discard(self, member_or_members, *args, **kwargs)
Removes a single member or multiple members from the set
source code
 
addMembers(self, nodes, force=False, ignore_failure=False)
Add items from iterable or selection list as members to this set
source code
 
removeMembers(self, nodes)
Remove items from iterable or selection list from this set
source code
 
setMembers(self, nodes, mode, **kwargs)
Adjust set membership for nodes
source code
    Member Query
 
getMembers(self, flatten=False)
Returns: MSelectionList with members of this set
source code
 
iterMembers(self, *args, **kwargs)
Iterate members of this set
source code
 
isMember(self, obj, component=api.MObject())
Returns: True if obj is a member of this set
source code
    Set Operations
 
_applySetOp(self, objects, opid, **kwargs)
Apply the set operation with the given id
source code
 
getUnion(self, objects, sets_are_members=False)
Create a union of the given items with the members of this set
source code
 
getIntersection(self, objects, sets_are_members=False)
As union, but returns the intersection ( items in common ) of this set with objects
source code
 
getDifference(self, objects, sets_are_members=False)
return the result of self minus objects, thus objects will be substracted from our obejcts
source code
 
iterUnion(self, setOrSetsOrObjects, **kwargs)
As union, but returns an iterator
source code
 
iterIntersection(self, setOrSetsOrObjects, **kwargs)
As intersection, but returns an iterator
source code
 
iterDifference(self, setOrSetsOrObjects, **kwargs)
As difference, but returns an iterator
source code
    Operators
 
__or__(self, objects, sets_are_members=False)
Create a union of the given items with the members of this set
source code
 
__add__(self, objects, sets_are_members=False)
Create a union of the given items with the members of this set
source code
 
__sub__(self, objects, sets_are_members=False)
return the result of self minus objects, thus objects will be substracted from our obejcts
source code
 
__and__(self, objects, sets_are_members=False)
As union, but returns the intersection ( items in common ) of this set with objects
source code
    Protocols
 
__len__(self) source code
 
__iter__(self) source code
 
__contains__(self, obj)
Returns: True if the given obj is member of this set
source code
Class Methods [hide private]
    Set Operations
 
_toValidSetOpInput(cls, objects, sets_are_members=False)
Method creating valid input for the union/intersection or difference methods
source code
 
tmpSet(cls, objects, sets_are_members=False)
Returns: temporary set that will delete itself once it's reference count reaches 0.
source code
Method Details [hide private]

partitions(self)

source code 
Returns:
list of Nodes of partitions the entity is set is part of

setPartition(self, partition, mode=0)

source code 
Add, add exclusive or remove the given partition from our partition list
Parameters:
  • partition - Node, representing the partition, or a list of such
  • mode -
    • 0 = replace
    • 1 = add
    • 2 = remove
Returns:
self for chained operations
Decorators:
  • @undoable

Note: use the supplied enumeration to specify the mode

_forceMembership(self, member, component, is_single_member, ignore_failure)

source code 
Search all sets connected to our partitions for intersecting members and remove them. Finally dd the members in question to us again
Parameters:
  • member - can be selection list or MObject, MDagPath, MPlug
Returns:
self if everything is fine

_checkMemberAddResult(self, member, component, mode, ignore_failure, is_single_member)

source code 
Check whether the given member has truly been added to our set and either force membership or raise and exception
Parameters:
  • is_single_member - if True, member can safely be assumed to be a single member, this speeds up operations as we do not have to use multi-member tests

_addRemoveMember(self, member, component, mode, ignore_failure)

source code 
Add or remove the member with undo support
Parameters:
  • mode - kRemove or kAdd

_addRemoveMembers(self, members, mode, ignore_failure)

source code 
Add or remove the members to the set
Parameters:
  • mode - kRemove or kAdd or kAddForce

clear(self)

source code 
Clear the set so that it will be empty afterwards
Returns:
self
Decorators:
  • @undoable

addMember(self, member, component=api.MObject(), force=False, ignore_failure=False)

source code 
Add the item to the set
Parameters:
  • member - Node, MObject, MDagPath or plug
  • force - if True, member ship will be forced by removing the member in question from the other set connected to our partitions
  • ignore_failure - if True, a failed add due to partion constraints will result in an exception, otherwise it will be silently ignored. Ignored if if force is True
  • component - if member is a dagnode, you can specify a component instance of type component instance ( Single|Double|TripleIndexComponent )
Returns:
self
Decorators:
  • @undoable

To Do: handle components - currently its only possible when using selection lists

add(self, member_or_members, *args, **kwargs)

source code 
Combined method which takes single or multiple members which are to be added
Parameters:
Decorators:
  • @undoable

Note: this method is for convenience only and should not be used to add massive amounts of items

removeMember(self, member, component=api.MObject())

source code 
Remove the member from the set
Parameters:
  • member - member of the list, for types see addMember
Decorators:
  • @undoable

discard(self, member_or_members, *args, **kwargs)

source code 
Removes a single member or multiple members from the set
Parameters:
Decorators:
  • @undoable

addMembers(self, nodes, force=False, ignore_failure=False)

source code 
Add items from iterable or selection list as members to this set
Parameters:
  • nodes - MSelectionList or list of Nodes and Plugs
  • force - see addMember
  • ignore_failure - see addMember
Returns:
self
Decorators:
  • @undoable

removeMembers(self, nodes)

source code 
Remove items from iterable or selection list from this set
Parameters:
Returns:
self
Decorators:
  • @undoable

setMembers(self, nodes, mode, **kwargs)

source code 
Adjust set membership for nodes
Parameters:
Decorators:
  • @undoable

getMembers(self, flatten=False)

source code 
Parameters:
  • flatten - if True, members that are objectSets themselves will be resolved to their respective members
Returns:
MSelectionList with members of this set
Notes:
  • the members are ordinary api objects that still need to be wrapped
  • use iterMembers to iterate the members as wrapped Nodes

iterMembers(self, *args, **kwargs)

source code 
Iterate members of this set
Notes:
  • All keywords of iterMembers are supported
  • if 'handlePlugs' is False, the iteration using a filter type will be faster
  • handleComponents will allow component iteration - see the iterator documentation

isMember(self, obj, component=api.MObject())

source code 
Parameters:
  • component - is given, the component must be fully part of the set for the object ( dagNode ) to be considered part of the set
Returns:
True if obj is a member of this set
Notes:
  • all keywords of it.iterSelectionList are supported
  • ismember does not appear to be working properly with component assignments. It returns true for components that are not actually in the givne shading group

members(self, flatten=False)

source code 
Parameters:
  • flatten - if True, members that are objectSets themselves will be resolved to their respective members
Returns:
MSelectionList with members of this set
Notes:
  • the members are ordinary api objects that still need to be wrapped
  • use iterMembers to iterate the members as wrapped Nodes

_toValidSetOpInput(cls, objects, sets_are_members=False)
Class Method

source code 
Method creating valid input for the union/intersection or difference methods
Parameters:
  • sets_are_members - see union
Notes:
  • it may return a temporary set that will delete itself once the wrapper object is being destroyed
  • set

tmpSet(cls, objects, sets_are_members=False)
Class Method

source code 
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
temporary set that will delete itself once it's reference count reaches 0. Use rval.setobj to access the actual set, as the returned object is just a hanlde to it. The handle is a valid input to the set functions as well

Note: useful if you want to use the set member union, intersection or substraction methods efficiently on many sets in a row - these internally operate on a set, thus it is faster to use them with another set from the beginning to prevent creation of intermediate sets

getUnion(self, objects, sets_are_members=False)

source code 
Create a union of the given items with the members of this set
Parameters:
  • objects - an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members - if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:
MSelectionList of all objects of self and objects

getIntersection(self, objects, sets_are_members=False)

source code 
As union, but returns the intersection ( items in common ) of this set with objects
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList of objects being in self and in objects

getDifference(self, objects, sets_are_members=False)

source code 
return the result of self minus objects, thus objects will be substracted from our obejcts
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList containing objects of self not being in objects list

iterUnion(self, setOrSetsOrObjects, **kwargs)

source code 
As union, but returns an iterator
Parameters:
  • kwargs - passed to it.iterSelectionList

iterIntersection(self, setOrSetsOrObjects, **kwargs)

source code 
As intersection, but returns an iterator
Parameters:
  • kwargs - passed to it.iterSelectionList

iterDifference(self, setOrSetsOrObjects, **kwargs)

source code 
As difference, but returns an iterator
Parameters:
  • kwargs - passed to it.iterSelectionList

union(self, objects, sets_are_members=False)

source code 
Create a union of the given items with the members of this set
Parameters:
  • objects - an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members - if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:
MSelectionList of all objects of self and objects

intersection(self, objects, sets_are_members=False)

source code 
As union, but returns the intersection ( items in common ) of this set with objects
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList of objects being in self and in objects

difference(self, objects, sets_are_members=False)

source code 
return the result of self minus objects, thus objects will be substracted from our obejcts
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList containing objects of self not being in objects list

__or__(self, objects, sets_are_members=False)
(Or operator)

source code 
Create a union of the given items with the members of this set
Parameters:
  • objects - an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members - if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:
MSelectionList of all objects of self and objects

__add__(self, objects, sets_are_members=False)
(Addition operator)

source code 
Create a union of the given items with the members of this set
Parameters:
  • objects - an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members - if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:
MSelectionList of all objects of self and objects

__sub__(self, objects, sets_are_members=False)
(Subtraction operator)

source code 
return the result of self minus objects, thus objects will be substracted from our obejcts
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList containing objects of self not being in objects list

__and__(self, objects, sets_are_members=False)
(And operator)

source code 
As union, but returns the intersection ( items in common ) of this set with objects
Parameters:
  • objects - see union
  • sets_are_members - see union
Returns:
MSelectionList of objects being in self and in objects

__len__(self)
(Length operator)

source code 

Warning: This method is possibly slow as it will retrieve all members just to get the size of the set. Don't use it directly if you like performance

__contains__(self, obj)
(In operator)

source code 
Returns:
True if the given obj is member of this set