Python Forum
How to make this piece concise
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make this piece concise
#1
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[:]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 656 Sep-05-2023, 12:50 PM
Last Post: ToniE
  First piece of code Bearwulf 2 723 Aug-02-2023, 04:03 PM
Last Post: deanhystad
  Understanding a piece of code Michael1 4 1,373 Jan-20-2022, 07:14 PM
Last Post: Michael1
  .maketrans() - a piece of code which needs some explanation InputOutput007 5 2,902 Jan-28-2021, 05:05 PM
Last Post: buran
  I am a newbie.Help me with this simple piece of code feynarun 3 2,752 Jan-08-2020, 12:40 PM
Last Post: perfringo
  How can I improve this piece of code? aquerci 3 2,172 Nov-17-2019, 10:57 AM
Last Post: Gribouillis
  Am i doing something wrong with this piece of code pythoneer 3 2,650 Mar-02-2018, 08:50 PM
Last Post: JustaNoOb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020