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

float

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

int

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
  • create/cr (bool) – recreate the target where possible; defaults to False

  • connect/con (bool) – after recreating the target, connect it back to the target; defaults to False if this is a ‘post’ target, otherwise False

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
  • shape (str, DagNode) – the geometry shape to use to drive this subtarget

  • connect/con (bool) – keep a live connection to the shape; this defaults to False if this is a post-mode target, otherwise True; passing True on a post-mode target will throw an error

Returns

self

Return type

Subtarget

disconnectShape()#

Disconnects the shape input, if any. Equivalent to self.geoInput.disconnect(inputs=True).

Returns

self

Return type

Subtarget

__int__()#
Returns

The logical (sparse) 5000 - > 6000 index for this subtarget (self.index)

Return type

int

__float__()#
Returns

The 0.0 -> 1.0 weight (value) for this subtarget (self.value)

Return type

float

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

Target

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.

Parameters
  • otherTarget (int, Target) – the target to copy deltas from; this must either be an index or a Target instance

  • replace/rep (bool) – clear deltas on this target before adding-in the copied ones; defaults to False

Returns

self

Return type

Target

export(filepath)#

Exports data for this target into the specified filepath.

Note

Data for inbetweens is not included. This is a Maya limitation.

Parameters

filepath (str) – the file path

Returns

self

Return type

Target

isTransformSpace()#
Returns

True if this is a transform-space target, else False.

Return type

bool

isTangentSpace()#
Returns

True if this is a tangent-space target, else False.

Return type

bool

inPostMode()#
Returns

True if this is a tangent- or transform-space target, otherwise False.

Return type

bool

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.

Parameters

transform (str, Transform) – the transform to connect

Raises

NonTransformSpaceTargetError – this is not a transform-space target

Returns

self

Return type

Target

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

Target

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.

Parameters

nid (int) – the normalization ID

Returns

self

Return type

Target

clearNormalizationId()#

Deleter for the normalizationId / nid property. Equivalent to setNormalizationId(0).

Returns

self

Return type

Target

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.

Parameters

alias (str) – the alias to set

Returns

self

Return type

Target

clearAlias()#

Removes the alias for this blend shape target (not usually advisable). Equivalent to setAlias(None). Deleter for the alias property.

Returns

self

Return type

Target

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 None

  • uv (bool) – flip in UV space; defaults to False

Returns

self

Return type

Target

getLogicalFromPhysicalIndex(physicalIndex)#
Parameters

physicalIndex (int) – the physical (contiguous) subtarget index

Returns

The logical (sparse, 5000 -> 6000) index.

Return type

int

getPhysicalFromLogicalIndex(logicalIndex)#
Parameters

logicalIndex (int) – the logical (sparse, 5000 -> 6000) subtarget index

Returns

The physical (contiguous) index.

Return type

int

getLogicalIndexFromValue(value)#
Parameters

value (float) – the 0.0 -> 1.0 subtarget value (ratio)

Returns

The matching logical (sparse, 5000 -> 6000) index.

Return type

int

getValueFromLogicalIndex(logicalIndex)#
Parameters

logicalIndex (int) – the sparse, 5000 -> 6000 subtarget index

Returns

The matching tween value (ratio).

Return type

float

values()#
Returns

The subtarget (tween) values (ratios).

Return type

[float]

indices()#
Returns

The logical (sparse, 5000 -> 6000) target indices.

Return type

[int]

getByLogicalIndex(logicalIndex)#

Retrieves a subtarget (tween) by logical (sparse, 5000 -> 6000) index.

Parameters

logicalIndex (int) – the logical subtarget index

Returns

The subtarget.

Return type

Subtarget

getByPhysicalIndex(physicalIndex)#

Retrieves a subtarget (tween) by logical (contiguous) index.

Parameters

physicalIndex – the physical subtarget index

Returns

The subtarget.

Return type

Subtarget

getByValue(value)#

Retrieves a subtarget (tween) by value (ratio).

Parameters

value (float) – the value (ratio)

Returns

The subtarget.

Return type

Subtarget

__len__()#
Returns

The number of subtargets (number of inbetweens + 1)

Return type

int

__iter__()#

Yields Subtarget instances.

__getitem__(logicalIndexOrValue)#

Retrieves subtargets by logical (5000 -> 6000) index or value (ratio).

Parameters

logicalIndexOrValue (float, int) – the value or logical index

Returns

The subtarget.

Return type

Subtarget

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

Subtarget

remove(subtarget)#

Removes a subtarget.

Parameters

subtarget (Subtarget) – The subtarget to remove.

Returns

self

Return type

Target

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.

Parameters

logicalIndex (int) – the logical (sparse / occupied, 5000 -> 6000) subtarget index

Returns

self

Return type

Target

removeByPhysicalIndex(physicalIndex)#

Removes the subtarget (tween) at the specified physical index. The main subtarget can’t be removed; use remove() on Targets instead.

Parameters

physicalIndex (int) – the physical (contiguous) subtarget index

Returns

self

Return type

Target

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.

Parameters

value (float) – the subtarget (tween) value (ratio)

Returns

self

Return type

Target

clearInbetweens()#

Removes all inbetweens.

Returns

self

Return type

Target

__delitem__(valueOrLogicalIndex)#

Removes a subtarget by logical (sparse / occupied, 5000 -> 6000) index or value (ratio).

Parameters

valueOrLogicalIndex (float, int) – The value or logical index.

__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__() or clear():

# 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

BlendShape

getLogicalIndexFromAlias(alias)#

Given an alias, returns the associated logical (sparse / in-use) target index.

Parameters

alias (str) – the target alias

Returns

The logical (sparse / in-use) target index.

Return type

int

getLogicalFromPhysicalIndex(physicalIndex)#
Parameters

physicalIndex – the physical (contiguous) target index

Returns

The logical (sparse / occupied) index.

Return type

int

getPhysicalFromLogicalIndex(logicalIndex)#
Parameters

logicalIndex – the logical (sparse / occupied) target index

Returns

the physical (contiguous) index

Return type

int

getAliasFromLogicalIndex(index)#

Given a logical (sparse / in-use) target index, returns the alias.

Parameters

index (int) – the logical (sparse / in-use) target index

Returns

The target alias.

Return type

str or None

getByAlias(alias)#
Parameters

alias – the alias for the target

Returns

The target.

Return type

Target

getByLogicalIndex(logicalIndex)#
Parameters

logicalIndex – the logical (sparse / occupied) index for the target

Raises

IndexError – the index doesn’t exist

Returns

The target.

Return type

Target

getByPhysicalIndex(physicalIndex)#
Parameters

logicalIndex – the physical (listed) index for the target

Raises

IndexError – the index doesn’t exist

Returns

The target.

Return type

Target

aliases()#
Returns

All available target aliases. None aliases are skipped.

Return type

[str]

indices()#
Returns

Logical (sparse) indices for the targets.

Return type

[int]

__getitem__(aliasOrLogicalIndex)#

Retrieves a target by alias or logical (sparse / occupied) index.

Parameters

aliasOrLogicalIndex (str, int) – the alias or logical (sparse / occupied) index

Returns

The target.

Return type

Target

__len__()#
Returns

The number of targets.

Return type

int

__iter__()#

Yields Target instances.

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 geometry

  • alias (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 None

  • tangentSpace/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

RuntimeError

  • 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

Target

__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.

Parameters
  • aliasOrLogicalIndex (str, int) – the target alias or logical (sparse / occupied) index

  • shape (str, GeometryShape, Transform,) – the shape to assign

removeByAlias(alias)#

Removes a target by alias.

Parameters

alias (str) – the target alias

Returns

self

Return type

Targets

removeByPhysicalIndex(physicalIndex)#

Removes a target by physical (contiguous) index.

Parameters

logicalIndex (int) – the physical (contiguous) index

Returns

self

Return type

Targets

removeByLogicalIndex(logicalIndex)#

Removes a target by logical (sparse / occupied) index.

Parameters

logicalIndex (int) – the logical (sparse / occupied) index

Returns

self

Return type

Targets

remove(target)#

Removes a target.

Parameters

target (Target) – the target to remove

Returns

self

Return type

Targets

__delitem__(aliasOrLogicalIndex)#

Removes a target by alias or logical (sparse / occupied) index.

Parameters

aliasOrLogicalIndex (str, int) – the alias or logical index

clear()#

Removes all targets.

Returns

self

Return type

Targets