Hi,
I have a problem with Rhino Python Editor and print command. Inside the script I’m opening Grasshopper Editor and document, so I guess this is causing the problem.
When I place the print command before loading GH Editor, it prints its output. After that, even when I close the GH document and close the GH Editor, it doesn’t print anything.
Any idea where could be (where could I make) the problem?
Thanks,
Tomas
import clr
clr.AddReferenceByName("Grasshopper")
import System
import Rhino
import Grasshopper
from Rhino import RhinoApp, RhinoDoc
import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp
import scriptcontext as sc
pt_a = Rhino.Geometry.Point3d(100,500,100)
pt_b = Rhino.Geometry.Point3d(1,0,0)
pt_c = Rhino.Geometry.Point3d(0,0,1)
plane = rs.PlaneFromNormal(pt_a, pt_c, pt_b)
mesh = rs.coercemesh("0a151cce-1aad-499b-87c7-744ac52b2b79")
gh = RhinoApp.GetPlugInObject("Grasshopper")
editor = gh.LoadEditor()
sh_editor = gh.ShowEditor()
document = gh.OpenDocument("d:\Kuka.gh")
docServer = Grasshopper.GH_InstanceServer.DocumentServer
doc0 = docServer[0] # first opened document
import Grasshopper.Kernel.GH_DocumentObject as DO
from Grasshopper.Kernel import GH_Param, GH_Convert, Parameters
def FindBatteryByNickname(docObjects, name):
if docObjects is None: return None
for obj in docObjects:
attr = obj.Attributes
if attr.PathName == name:
return obj
raise Exception(name + " was not found in document")
pln = FindBatteryByNickname(doc0.Objects, "Plane")
msh = FindBatteryByNickname(doc0.Objects, "Mesh")
out = FindBatteryByNickname(doc0.Objects, "output")
axis = FindBatteryByNickname(doc0.Objects, "axis")
gh.AssignDataToParameter(str(pln.InstanceGuid), plane)
gh.AssignDataToParameter(str(msh.InstanceGuid), mesh)
gh.RunSolver(False)
out_data = str(out.VolatileData[0][0])
axis_data = []
for i in range(6):
axis_data.append(float(str(axis.VolatileData[0][i])))
print out_data, axis_data
sv_doc = gh.SaveDocument()
cl_doc = gh.CloseDocument()
hid_editor = gh.HideEditor()
sc.doc = RhinoDoc.ActiveDoc
mesh2 = rs.coercemesh("0a151cce-1aad-499b-87c7-744ac52b2b79")
print mesh2