1.) rs.GetObjects returns a list of of object ids, not one. Thus getset_material(base_geo) is passing a list to getset_material which is expecting just one.
2.) Watch your indenting - Python is very particular about this.
I’m pretty sure the issue was with the list return on GetObjects. I do intend do set this up to iterate through lists of objects eventually, so i want to keep it that way.
calling
getset_material(base_geo[0]) solves the problem.
i think my indent issues are more to do with sucking at forums than python :P.
here’s my new working code. Thanks again.
import rhinoscriptsyntax as rs
def getset_material(object_id):
if object_id:
mat_label = rs.IsUserText(object_id)
if mat_label != 1:
value = raw_input("Please set a material for this obect (i.e. hardwood, oak, etc.)")
key = "Material"
rs.SetUserText(object_id, key, value)
else:
print rs.GetUserText (object_id, "Material") #returns nothing
base_geo = rs.GetObjects ( message=None, filter=1073741840, group=False, preselect=True, select=True, objects=None, minimum_count=1, maximum_count=1, custom_filter=None )
getset_material(base_geo[0])