I am trying to set the object name of a mesh to the name of the file as part of a workflow. I thought I had it with the below script, but the OBJ name is not set to the file name, but just to “m” in any file I try.
import rhinoscriptsyntax as rs
def ObjNamefromFile():
Docs=rs.DocumentName()
for Name in Docs:
objs=rs.ObjectsByType(32, True)
rs.ObjectName(objs,Name)
ObjNamefromFile()
Hi @codywils101 ,
You are currently iterating through all characters in the document name. Instead, you should iterate through object list, and change their names.
import rhinoscriptsyntax as rs
def ObjNamefromFile():
docName=rs.DocumentName()
docName = docName.replace('.3dm','')#removing extension if needed
objs=rs.ObjectsByType(32, True)
for obj in objs:
rs.ObjectName(obj,docName)
ObjNamefromFile()
1 Like
Thank you very much! I am a novice with python, sometimes the simple stuff alludes me.
1 Like