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
Question I'm trying to make a piece of code Alislugacool 5 3,267 Sep-13-2025, 06:11 AM
Last Post: MilesWeb
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 2,386 Sep-05-2023, 12:50 PM
Last Post: ToniE
  First piece of code Bearwulf 2 1,877 Aug-02-2023, 04:03 PM
Last Post: deanhystad
  Understanding a piece of code Michael1 4 3,005 Jan-20-2022, 07:14 PM
Last Post: Michael1
  .maketrans() - a piece of code which needs some explanation InputOutput007 5 5,084 Jan-28-2021, 05:05 PM
Last Post: buran
  I am a newbie.Help me with this simple piece of code feynarun 3 4,379 Jan-08-2020, 12:40 PM
Last Post: perfringo
  How can I improve this piece of code? aquerci 3 3,672 Nov-17-2019, 10:57 AM
Last Post: Gribouillis
  Am i doing something wrong with this piece of code pythoneer 3 4,023 Mar-02-2018, 08:50 PM
Last Post: JustaNoOb

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.