![]() |
How to make this piece concise - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to make this piece concise (/thread-35016.html) |
How to make this piece concise - leoahum - Sep-23-2021 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[:] |