Rename pageviews/layout by print order

import Rhino 
import Rhino.Geometry as rg
import scriptcontext as sc
import rhinoscriptsyntax as rs
import math

sc.doc = Rhino.RhinoDoc.ActiveDoc

def RenameLayootWithSerialName():
    layouts = rs.ViewNames(False,1)
    prefix = rs.GetString("input prefix of layout",False,False)
    
    for i in range(len(layouts)):
        newname = str(prefix)+'-'+str(i+1).zfill(2)
        rs.RenameView(layouts[i],str(newname))


RenameLayootWithSerialName()

I wrote this script to help me rename pageviews/layout,
but it doesn’t work the way I want,
it rename pageviews/layout by create order not print order,
image
image

I really need it to rename by print order,so that i could insert new page in pageviews.

If anyone can help me with this
This will be great.

Hi @cy.huang.archi,

Attached is a sample script to sort layouts. I am sure it doesn’t do what you want. But it might give you an idea or two.

test_pageviews_sort_ascending.py (902 Bytes)

– Dale

Thank you!
it really helps me a lot,
I’ll learn form it ,and try to improve my script