MoveSequence Method


Moves all elements of a numbering sequence from one partition to another.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2015

Syntax

C#
public void MoveSequence(
	string fromPartition,
	string newPartition
)
Visual Basic
Public Sub MoveSequence ( _
	fromPartition As String, _
	newPartition As String _
)
Visual C++
public:
void MoveSequence(
	String^ fromPartition, 
	String^ newPartition
)

Parameters

fromPartition
Type: System String
Name of the partition that determines which numbering sequence to move. The sequence must exist already, otherwise an exception will be thrown.
newPartition
Type: System String
Name of a partition into which the source sequence is going to be moved. The schema must not have a sequence for this partition yet (i.e. the schema does not have an element that was assigned to such a partition.)

Leading and trailing white space is ignored in the given string and will be removed automatically.

Remarks

All numbers assigned to elements in the sequence remain the same.

This operation modifies the Partition parameter of all elements in the given sequence. Therefore, all the elements must be accessible for editing.

Elements can be moved only to a partition that does not exist yet. To move elements to an existing partition use the AppendSequence method.

Examples

Copy C#
/// <summary>
/// This method uses multiple moving operations to swap numbers
/// for Rebars in two numbering sequences. The sequences are
/// identified by the names of two numbering partitions.
/// </summary>
/// <param name="document">Document to modify</param>
/// <param name="part1">Name of the partition of one numbering sequence</param>
/// <param name="part2">Name of the partition of another numbering sequence</param>
private void SwapNumberingSequences(Document document, string part1, string part2)
{
    // Obtain a schema object for a particular kind of elements 
    NumberingSchema schema = NumberingSchema.GetNumberingSchema(document,NumberingSchemaTypes.StructuralNumberingSchemas.Rebar);

    using (Transaction transaction = new Transaction(document))
    {
        // Changes to numbering sequences must be made inside a transaction
        transaction.Start("Swap Numbering Sequences");

        // We will use a temporary partition for the swap operation,
        // for the move operation only works if the target partition 
        // does not exist yet in the same numbering schema.
        // (We assume this TEMPORARY partition does not exist.)
        string tempPartition = "TEMPORARY";

        // Step 1
        // First we move all elements from one sequence into 
        // a partition we know does not exist. This action will
        // create the temporary partition and remove the original
        // one (part1).
        schema.MoveSequence(part1, tempPartition);

        // Step 2
        // With the sequence in partition 'part1' removed
        // we can now move elements from the second sequence to it.
        // This action will re-create a sequence in partition 'part1'
        // and remove the sequence in partition 'part2'
        schema.MoveSequence(part2, part1);

        // Step 3
        // Finally, we can move elements 'parked' in the temporary
        // sequence to partition 'part2', for that partition was
        // removed in the previous step and thus can now be created
        // again. The temporary partition will be automatically 
        // removed upon completing this step.
        schema.MoveSequence(tempPartition, part2);

        transaction.Commit();
    }
}
Copy VB.NET
''' <summary>
''' This method uses multiple moving operations to swap numbers
''' for Rebars in two numbering sequences. The sequences are
''' identified by the names of two numbering partitions.
''' </summary>
''' <param name="document">Document to modify</param>
''' <param name="part1">Name of the partition of one numbering sequence</param>
''' <param name="part2">Name of the partition of another numbering sequence</param>
Private Sub SwapNumberingSequences(document As Document, part1 As String, part2 As String)
    ' Obtain a schema object for a particular kind of elements 
    Dim schema As NumberingSchema = NumberingSchema.GetNumberingSchema(document, NumberingSchemaTypes.StructuralNumberingSchemas.Rebar)

    Using transaction As New Transaction(document)
        ' Changes to numbering sequences must be made inside a transaction
        transaction.Start("Swap Numbering Sequences")

        ' We will use a temporary partition for the swap operation,
        ' for the move operation only works if the target partition 
        ' does not exist yet in the same numbering schema.
        ' (We assume this TEMPORARY partition does not exist.)
        Dim tempPartition As String = "TEMPORARY"

        ' Step 1
        ' First we move all elements from one sequence into 
        ' a partition we know does not exist. This action will
        ' create the temporary partition and remove the original
        ' one (part1).
        schema.MoveSequence(part1, tempPartition)

        ' Step 2
        ' With the sequence in partition 'part1' removed
        ' we can now move elements from the second sequence to it.
        ' This action will re-create a sequence in partition 'part1'
        ' and remove the sequence in partition 'part2'
        schema.MoveSequence(part2, part1)

        ' Step 3
        ' Finally, we can move elements 'parked' in the temporary
        ' sequence to partition 'part2', for that partition was
        ' removed in the previous step and thus can now be created
        ' again. The temporary partition will be automatically 
        ' removed upon completing this step.
        schema.MoveSequence(tempPartition, part2)

        transaction.Commit()
    End Using
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The sequence fromPartition does not exist in the schema. -or- The sequence newPartition does already exist in the schema. -or- the given newPartition cannot be used as a valid name of a numbering partition because it contains characters that are considered invalid, such as non-printable characters or those that cannot be used in a file's name.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions InvalidOperationException Either the schema or its document cannot be modified at present. -or- Thrown if there is an element that cannot have new value of the NUMBER_PARTITION_PARAM parameter assigned. It may be an indication that the element is not free to be edited at present.

See Also