paya.lib.bsnboltons#
This module is not for direct import / use. It defines the .targets
interface on BlendShape
.
- subtargetIndexToValue(index)#
Given a logical subtarget (tween) index in the 5000 -> 6000 range, returns a float weight.
- Parameters
index – the logical subtarget index
- Returns
The weight.
- Return type
- subtargetValueToIndex(value)#
Given a subtarget (tween) value, returns a logical index in the 5000 -> 6000 range.
- Parameters
value – the subtarget value
- Returns
The index.
- Return type
- class Subtarget(index, owner)#
Interface for editing subtargets (tweens).
Updating geometry
target = bsn.targets['L_smile'] subtarget = target[1.0] subtarget.shape = 'new_geo'
- getShape(create=False, connect=None)#
- Parameters
- Returns
The shape connected into this target. This may be None if this is a ‘post’ mode target, or if targets were disconnected or deleted by the rigger.
- Return type
GeometryShape
- setShape(shape, connect=None)#
- Parameters
- Returns
self
- Return type
- disconnectShape()#
Disconnects the shape input, if any. Equivalent to
self.geoInput.disconnect(inputs=True)
.- Returns
self
- Return type
- __int__()#
- Returns
The logical (sparse) 5000 - > 6000 index for this subtarget (
self.index
)- Return type
- class Target(index, owner)#
Retrieving Subtargets (Tweens)
# Start target = bsn.targets['L_smile'] # Iterate subtargets for subtarget in target: # do something # List subtargets list(target) # By logical (sparse, 5000 -> 6000) index subtarget = target.getByLogicalIndex(logicalIndex) # By physical (contiguous) index subtarget = target.getByPhysicalIndex(physicalIndex) # or subtarget = list(taret)[physicalIndex] # By value (ratio) subtarget = target.getByValue(value) # or subtarget = target[value]
Adding Subtargets (Tweens)
subtarget = target.add(0.5, tweenShape) # or target[0.5] = tweenShape # by value # or target[5500] = tweenShape # by logical index
See
add()
for more options.Removing Subtargets (Tweens)
target.removeByPhysicalIndex(physicalIndex) target.removeByLogicalIndex(logicalIndex) target.removeByValue(value) # or del(target[physicalIndex]) del(target[value]) # Clear all inbetweens (but not at 1.0) target.clearInbetweens()
See
Subtarget
for more.- resetDelta()#
Clear delta values for all subtargets on this target. This will only have an effect if there is no live shape input.
- Returns
self
- Return type
- copyDeltaFrom(otherTarget, replace=False)#
Copies delta information from ‘otherTarget’. This will only have an effect if there is no live shape input.
Note
Deltas for inbetweens are not included.
- export(filepath)#
Exports data for this target into the specified filepath.
Note
Data for inbetweens is not included. This is a Maya limitation.
- inPostMode()#
- Returns
True if this is a tangent- or transform-space target, otherwise False.
- Return type
- getTransform()#
Setter for the
transform
/xf
property.- Raises
NonTransformSpaceTargetError – this is not a transform-space target
TargetMatrixNotATransformError – there’s an input into .targetMatrix, but it’s from a utility node
- Returns
if this is a transform-space target, the transform connected to it
- Return type
None,
Transform
- setTransform(transform)#
If this is a transform-space target, connects the
.worldMatrix
of the specified transform into its.targetMatrix
attribute.Setter for the
transform
/xf
property.
- clearTransform()#
” If this is a transform-space target, clears any inputs on its
.targetMatrix
attribute.Deleter for the
transform
/xf
property.- Raises
NonTransformSpaceTargetError – this is not a transform-space target
- Returns
self
- Return type
- getNormalizationId()#
Getter for the
normalizationId
/nid
property.- Returns
The normalization ID of this target. An ID of 0 means that the target doesn’t belong to any normalization groups.
- Return type
int or None
- setNormalizationId(nid)#
Sets the normalization ID of this target. An ID of 0 means that the target doesn’t belong to any normalization groups.
Setter for the
normalizationId
/nid
property.
- clearNormalizationId()#
Deleter for the
normalizationId
/nid
property. Equivalent tosetNormalizationId(0)
.- Returns
self
- Return type
- getAlias()#
Returns the alias for this blend shape target. Getter for the
alias
property.- Returns
The alias for this target, if any.
- Return type
str or None
- setAlias(alias)#
Sets the alias for this blend shape target. Setter for the
alias
property.
- clearAlias()#
Removes the alias for this blend shape target (not usually advisable). Equivalent to
setAlias(None)
. Deleter for thealias
property.- Returns
self
- Return type
- flip(mirrorDirection=1, symmetryAxis='x', symmetryEdge=None, uv=False)#
Flips this blend shape target.
- Parameters
mirrorDirection (int) – 1 for positive along, -1 for negative; defaults to 1
symmetryAxis/sa (str) – one of ‘X’, ‘Y’, or ‘Z’
symmetryEdge/se (str, int,
MeshEdge
, list) – this can be a single edge, or a list of two; the edges can be specified as simple integers, or fully-specified components on the base object; defaults to Noneuv (bool) – flip in UV space; defaults to False
- Returns
self
- Return type
Target
- getLogicalFromPhysicalIndex(physicalIndex)#
- getPhysicalFromLogicalIndex(logicalIndex)#
- getLogicalIndexFromValue(value)#
- getValueFromLogicalIndex(logicalIndex)#
- getByLogicalIndex(logicalIndex)#
Retrieves a subtarget (tween) by logical (sparse, 5000 -> 6000) index.
- getByPhysicalIndex(physicalIndex)#
Retrieves a subtarget (tween) by logical (contiguous) index.
- Parameters
physicalIndex – the physical subtarget index
- Returns
The subtarget.
- Return type
- getByValue(value)#
Retrieves a subtarget (tween) by value (ratio).
- __getitem__(logicalIndexOrValue)#
Retrieves subtargets by logical (5000 -> 6000) index or value (ratio).
- add(value, geometry, relative=False, topologyCheck=False, connect=None)#
Adds a subtarget (tween) at the specified value (ratio).
- Parameters
value (float) – the value at which to add the subtarget
geometry – the geometry shape to assign
topologyCheck/tc (bool) – check topology before applying; defaults to False
relative/rel (bool) – create a ‘relative’ inbetween target; defaults to False
connect/con (bool) – connect the target; defauls to True if this is a pre-deformation blend shape, otherwise False
- Raises
RuntimeError – the requested value (ratio) is already in use
- Returns
The new Subtarget instance.
- Return type
- remove(subtarget)#
Removes a subtarget.
- removeByLogicalIndex(logicalIndex)#
Removes the subtarget (tween) at the specified logical index. The main subtarget (at 6000 / 1.0) can’t be removed; use remove() on
Targets
instead.
- removeByPhysicalIndex(physicalIndex)#
Removes the subtarget (tween) at the specified physical index. The main subtarget can’t be removed; use remove() on
Targets
instead.
- removeByValue(value)#
Removes the subtarget (tween) at the specified value (ratio). The main subtarget (at 1.0) can’t be removed; use remove() on
Targets
instead.
- __delitem__(valueOrLogicalIndex)#
Removes a subtarget by logical (sparse / occupied, 5000 -> 6000) index or value (ratio).
- __int__()#
- Returns
The logical (sparse) index for this target group.
- class Targets(owner)#
Interface for editing blend shape targets, available on
BlendShape
instances as.targets
/.t
.Retrieving Targets
# Iteration for target in bsn.targets: # do something # Listing list(bsn.targets) # By logical (sparse / occupied) index: target = bsn.targets.getByLogicalIndex(logicalIndex) # or: target = bsn.targets[logicalIndex] # By physical (contiguous) index: target = bsn.targets.getByPhysicalIndex(physicalIndex) # or: target = list(bsn.targets)[physicalIndex] # By alias: target = bsn.targets.getByAlias(alias) # or: target = bsn.targets[alias]
Adding Targets
target = bsn.targets.add(geometry) # or target[alias] = geometry
See
add()
for more options.Removing Targets
Use
removeByPhysicalIndex()
,removeByLogicalIndex()
,removeByAlias()
,__delitem__()
orclear()
:# By logical index: bsn.targets.removeByLogicalIndex(logicalIndex) # or del(bsn.targets[logicalIndex]) # By physical index bsn.targets.removeByPhysicalIndex(physicalIndex) # By instance target = bsn.targets.add(geometry) bsn.targets.remove(target) # By alias bsn.targets.removeByAlias('L_smile') # or del(bsn.targets['L_smile']) # Clear all targets bsn.clear()
See
Target
for additional methods for subtargets (tweens) etc.- node()#
- Returns
The owner blend shape node.
- Return type
- getLogicalIndexFromAlias(alias)#
Given an alias, returns the associated logical (sparse / in-use) target index.
- getLogicalFromPhysicalIndex(physicalIndex)#
- Parameters
physicalIndex – the physical (contiguous) target index
- Returns
The logical (sparse / occupied) index.
- Return type
- getPhysicalFromLogicalIndex(logicalIndex)#
- Parameters
logicalIndex – the logical (sparse / occupied) target index
- Returns
the physical (contiguous) index
- Return type
- getAliasFromLogicalIndex(index)#
Given a logical (sparse / in-use) target index, returns the alias.
- getByAlias(alias)#
- Parameters
alias – the alias for the target
- Returns
The target.
- Return type
- getByLogicalIndex(logicalIndex)#
- Parameters
logicalIndex – the logical (sparse / occupied) index for the target
- Raises
IndexError – the index doesn’t exist
- Returns
The target.
- Return type
- getByPhysicalIndex(physicalIndex)#
- Parameters
logicalIndex – the physical (listed) index for the target
- Raises
IndexError – the index doesn’t exist
- Returns
The target.
- Return type
- __getitem__(aliasOrLogicalIndex)#
Retrieves a target by alias or logical (sparse / occupied) index.
- add(targetGeo, alias=None, topologyCheck=False, transform=None, tangentSpace=None, initWeight=0.0, index=None, connect=None)#
Adds a blend shape target.
- Parameters
targetGeo (str,
GeometryShape
,Transform
) – the target geometryalias (None, str) – an optional alias for the target; if omitted, defaults to the geometry’s base name
topologyCheck/tc (bool) – check topology when applying; defaults to False
transform/tr (None, str,
DagNode
) – if this is provided, and the blend shape node is in ‘post-deformation’ mode, a transform-space target will be configured; defaults to NonetangentSpace/ts (bool) – if the blend shape node is in ‘post-deformation’ mode, configure a tangent-space target; defaults to False
initWeight/iw (float) – the blend shape weight value on creation; defaults to 0.0
connect/con (bool) – connect the source shape; defaults to True if the blend shape node is in ‘pre-deformation’ mode, otherwise False
index/i (int) – a preferred logical (sparse) index for the target; this mustn’t already exist; if omitted, defaults to the next non- contiguous index.
- Raises
both transform and tangent were specified
either transform or tangent were specified and the blend shape node is not in ‘post-deformation’ mode
the requested or derived alias is already in use
the requested logical index is already in use
- Returns
The target instance.
- Return type
- __setitem__(aliasOrLogicalIndex, shape)#
Performs quick target editing via direct geometry assignments. Note that, if a matching item is found, any existing inbetween shapes will be removed. To preserve them, perform the same operation on a subtarget via
Target
instead.
- removeByAlias(alias)#
Removes a target by alias.
- removeByPhysicalIndex(physicalIndex)#
Removes a target by physical (contiguous) index.
- removeByLogicalIndex(logicalIndex)#
Removes a target by logical (sparse / occupied) index.
- remove(target)#
Removes a target.
- __delitem__(aliasOrLogicalIndex)#
Removes a target by alias or logical (sparse / occupied) index.