Close

Experimental:Sequence Class

An object describing and controlling a set of sequential parameters. Accessed via

mySequence = op('/add1').par.point0weight.sequence	# get the sequence object
alsoMySequence = op('/add1').seq.point				# another way to get the sequence object

# A sequence block is a SequenceBlock object, which gives access to one set of parameters in the sequence.
print(len(seq))									# number of sequence blocks in the sequence
print(seq[0])									# first sequence block in the sequence
for parBlock in seq:
	print([par for par in parBlock])			# print all sequence blocks
seq.numBlocks += 1							    # add a new sequence block (same as pressing + in the UI)

# Example 2
# Examine siblings of a constant CHOP sequence

n = op('/project1/constant1')
p = n.par.const2name
p.sequenceBlock.par.name  # const2name
p.sequenceBlock.par.value  # const2value

See also: Sequential Parameters, SequenceBlock Class, SequenceCollection Class



Members

blockSizeint :

Get or set the sequence blocksize.

blocks(Read Only):

The set of all blocks in this sequence. A block is a set of parameters which can be repeated in an operator. See SequenceBlock class.

maxBlocksint or None (Read Only):

The maximum number of blocks allowed in the sequence, or None if limitless.

namestr :

Get or set the sequence name, which affects all its parameter names.

numBlocksint :

Get or set the total number of parameter blocks in this sequence.

ownerOP (Read Only):

The OP to which this object belongs.

blockParslist (Read Only):

An intermediate parameter collection object, from which specific sequence parameters can be found.

Returns a list of one parameter from each block.

n.seq.Info.blockPars.Tx
n.seq.Info.blockPars.Tx[3] #Par from 4th block.
n.seq.Info.blockPars['Tx'] #returns None if not found.

blockParGroupslist (Read Only):

An intermediate parGroup collection object, from which specific sequence parameter groups can be found.

Returns a list of one parGroup from each block.

n.seq.Info.blockParGroups.T
n.seq.Info.blockParGroups.T[3] #ParGroup from 4th block.
n.seq.Info.blockParGroups['T'] #returns None if not found.

sequencePar(Read Only):

The main sequence parameter defining this sequence.

Methods

[block index]SequenceBlock:

Sequence blocks may be easily accessed using the [] subscript and assignment operators.

  • block index - The index of the desired block.

destroyBlock(block)None:

Destroy the block of parameters at the given location.

  • block - The index of the existing block to destroy.

insertBlock(block)SequenceBlock:

Insert a block of parameters at the given location.

  • block - The index of the new block to insert.

Returns the newly created block.

reorderBlocks(*indexes)None:

Reorder the specified blocks, leaving the rest in place.

  • indexes - Integer indexes of the blocks to reorder, in their new order.

Example:

n.seq.Info.reorderBlocks(1,0)
# swaps position of first two blocks

sortBlocks(key=lambda Block, baseName="", reverse=False)None:

Sorts the blocks based on the given key function or baseName parameter. If both are provided, an exception will be raised.

  • key - A function that is passed every block in the sequence and which returns a sortable value. By default it evaluates the block's name parameter, if defined, otherwise it sorts by the first parameter of the block.
  • baseName - If specified, sort by the values of the parameter with this name.
  • reverse - If True, reverses the order of the sort.

Examples:

n.seq.Info.sortBlocks(reverse=True) # just reverse current order
n.seq.Info.sortBlocks(baseName='Value') # sort by the evaluation of <code>Value</code> parameters in each block
n.seq.Info.sortBlocks(key=lambda block: block.par.Key) # sort by the evaluation of <code>Key</code> parameters in each block
n.seq.Info.sortBlocks(key=lambda block: block.par.X + block.par.Y) # sort on the sum of X and Y parameters in each block
n.seq.Info.sortBlocks(key=lambda block: (block.par.X, block.par.Y)) # sort by X parameter, then Y parameter within that.