The following code fails when the matching text field hasn’t been added to the document once. Even after adding the text field to the document and deleting it afterward, the code still runs fine. How can I add this text field to the document (and delete it afterward), or is there another way around this?
import Rhino
import scriptcontext as sc
def part_of_code():
pageview = sc.doc.Views.ActiveView
pageview.SetPageAsActive()
id = str(pageview.ActiveViewportID)
try:
page_scale = Rhino.Runtime.TextFields.LayoutUserText(id, "page_scale")
except:
print "something went wrong"
return
part_of_code()