Hello !!
I have successfully been working with a simple python script exporting STL files for months. It was part of a much bigger python script etc.
It suddenly stopped working and I cannot even get my very first downloaded (?) script to work. I did not update anything, kept working with Rhino 6, same Python, same everything. I know this is the usual newby beginner statement. hahaha
I get the following error:
‘NoneType’ object has no attribute ‘Geometry’
Component inputs and settings are the same (Type Hint + List Access). This is the same gh file that was working before.
I also removed the “cache” just in case even though I do not think that is the problem.
What did change ? Why my coercerhinoobject cannot retrieve the geometry etc ?
THANK YOU !!
bake_into_rhinov3.gh (7.7 KB)
It is happening in BatchExportSTLByObject:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import subprocess
def GetSTLSettings():
e_str = "_ExportFileAs=_Binary "
e_str+= "_ExportUnfinishedObjects=_Yes "
e_str+= "_UseSimpleDialog=_Yes "
e_str+= "_UseSimpleParameters=_Yes "
e_str+= "_Enter _Enter"
return e_str
def BatchExportSTLByObject():
filepath=rs.DocumentPath()
stl_sett = GetSTLSettings()
if active:
for i in range(len(geo)):
e_file_name = "{}-{}.stl".format(filename, str(i))
geo_id = geo[i]
doc_object = rs.coercerhinoobject(geo_id)
geometry = doc_object.Geometry
attributes = doc_object.Attributes
# -----> we change the scriptcontext
sc.doc = Rhino.RhinoDoc.ActiveDoc
#we add both the geometry and the attributes to the Rhino doc
rhino_line = sc.doc.Objects.Add(geometry, attributes)
rs.SelectObject(rhino_line)
# <----- we put back the original Grasshopper document as default
sc.doc = ghdoc
rs.Command("-_Export " + filepath + e_file_name + " " + stl_sett, False)
# -----> we change the scriptcontext
sc.doc = Rhino.RhinoDoc.ActiveDoc
rs.DeleteObject(rhino_line)
# <----- we put back the original Grasshopper document as default
sc.doc = ghdoc
BatchExportSTLByObject()
sc.doc = Rhino.RhinoDoc.ActiveDoc
return_code = subprocess.call("echo Hello World", shell=True)
print(return_code)