View Single Post
# 1 28-10-2020 , 04:53 PM
Registered User
Join Date: Jan 2020
Posts: 7

Maya Script reading txt-file and interpret data

Hello world!
I am currently experimenting with txt files inside maya. F.e.
"
1 sphere
2 cube
3 cylinder
4 cone
5 plane

"

The left column reflects a frame number and the right an objectname.
I want to read the file and interact with an object only for a specific frame. For example switching the visibility of an object on and off.

this is what i got so far:

fileHandle = open('c:\\text.txt', 'r' )
str1 = fileHandle.read()
fileHandle.close()
print str1

(This doesn't have to be written in Python. MEL is perfect aswell)
I know how to read the file and save it to an string but not how to navigate inside.
Perhaps someone is experienced enough to help user added image
Thank you very user added image