Hi everyone.
In Rhino 8 and grasshopper
I’m trying to iteratively print a layout, as a pdf, that updates based on a slider.
The process is:
Update slider (automatically), graphics and annotations on a layout change, print that to pdf (using a python script shown below)
I tried using Animate Slider, this works, but for some prints I think it prints before the layout is completely refreshed, so some geometry/ annotations are missing. The images (of the view) saved by this process are correct, but the pdf printed isn’t always correct.
So, I added a python script to generate a series of numbers with delay.
With this I can see the view getting updated correctly, but the sheets being printed do not include any dynamic annotations or geometry from grasshopper.
I’m using the same python script to print for both of these methods.
Any suggestions are welcome.
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import time
import Grasshopper as gh
def updateComponent(interval):
# Schedule a new solution after a specified time interval.
# https://discourse.mcneel.com/t/ghpython-counter-from-0-to-a-value/121290/2
# https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_Kernel_GH_Document_ScheduleSolution_1.htm
# https://stackoverflow.com/questions/9596276/how-to-explain-callbacks-in-plain-english-how-are-they-different-from-calling-o
def callBack(e):
ghenv.Component.ExpireSolution(False)
ghenv.Component.OnPingDocument().ScheduleSolution(interval, gh.Kernel.GH_Document.GH_ScheduleDelegate(callBack))
if "count" not in globals() or reset:
count = 0
if run and count<len(input_list):
if run and not reset and count<len(input_list):
count += 1
input_val = input_list[count-1]
model_id = str(input_val)
updateComponent(wait_time*1000)
counter = count
Code for printing
filepath, filettitle,
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import time
filename = filepath + '\\' + filetittle
pages = sc.doc.Views.GetPageViews()
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
for page in pages:
# page.Redraw()
capture = Rhino.Display.ViewCaptureSettings(page, dpi)
pdf.AddPage(capture)
pdf.Write(filename)
a = filetittle