Running the same script in R6 returns False, although the PNG image is successfully created. Is there any reason why I’m getting a ‘False’ return value now?
So I think I shot my self in the foot here by not properly enclosing the file path (which has spaces in it) in double inverted commas. Also, it seems the file name came directly after -ViewCaptureToFile in R5, but needs to be the last argument in R6. This works:
# Warning: Width and Height options persist when the command is run in scripting mode
view_size = rs.ViewSize()
common_options = " _Width={w} _Height={h}".format(w=view_size[0],h=view_size[1])
common_options += " _Scale={s}".format(s=self.scale)
common_options += " _DrawGrid=_No _DrawWorldAxes=_No _DrawCPlaneAxes=_No"
if rs.ExeVersion() < 6:
# Rhino 5 had a bug with transparent backgrounds
transp = '_No'
cmd = '-_ViewCaptureToFile "{f}"'.format(f=file_name)
cmd += common_options
cmd += " _TransparentBackground={t}".format(t=transp)
cmd += " _Enter"
else:
transp = '_Yes'
cmd = '-_ViewCaptureToFile'
cmd += common_options
cmd += " _TransparentBackground={t}".format(t=transp)
#cmd += " _Unit=pixels _LockAspectRatio=_Yes _ScaleDrawing=_No"
#cmd += " _NumberOfPasses=50"
cmd += ' "{f}"'.format(f=file_name)
cmd += " _Enter"
rs.Redraw()
success = rs.Command(cmd, echo=False)
if not success:
print("Error capturing PNG image.")
return False