Hello,
I have a python script running like a charm excepted that I do not recover any control on the canvas (GH window) afterwards. I have to quit and relaunch Rhino and GH.
------ First:
import rhinoscriptsyntax as rs
import scriptcontext as sc
------ Then, I am changing the scriptcontext using:
sc.doc = Rhino.RhinoDoc.ActiveDoc
------ I can then call commands:
rhino_line = sc.doc.Objects.Add(geometry, attributes)
rs.UnselectAllObjects()
rs.SelectObject(rhino_line)
rs.Command("-_Export " + filepath + filename + " " + settings, False)
rs.DeleteObject(rhino_line)
------ I then put back the original Grasshopper document as default using:
sc.doc = ghdoc
I got it working by playing with the order of those “sc.doc” commands. But it does not seem to work all the time and I do not see what I am doing wrong.
I tried in vain to add a timer after the writing of the file in case GH was not waiting for the system to store the file.
Thank you !!