Python Forum

Full Version: How to make this piece concise
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am setting up a script in a 3D modeling program called Rhino(Use ironPython) and its Visual Scripting Tool (Grasshopper). "Active" is an input boolean value. "a" is to output the result. Before the "Active" happened as an input, there is nothing to assign "a" to. So, there is the "Try "section. The script works fine. How can I better script this?

Thanks!

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
# import library

#get all the layout names in Rhino
def AllPageName():
    pages = sc.doc.Views.GetPageViews()
    PageNames = [i.PageName for i in pages]
    return PageNames

    
if __name__ == "__main__" and Active:
    PageNameList = AllPageName()

#Before Input
try: PageNameList
except NameError:
    PageNameList = None

if PageNameList == None:
    a = "Active the Node"
else:
    a = PageNameList[:]