Hi there,
I am using userText for almost everything I do in Rhino. I’d like to implement a short python script which would allow the user to pick a CSV filename, then read it, and send the values to object’s userText.
CSV files would only contain two colums (ObjectName and Value). The userText Key is written by the user in the command line.
Does anybody has already a python code doing something similar ? It would be useful and will give me a start. Then, I will add few checks and specific rules on object’s types and string formatting.
Thanks
Hi,
I have made this :
CSV to UserText.7z (31.4 KB)
This is a start, any comment would be appreciated. Mostly concerning the message box in which texts are not fully displayed …
Thanks
Hi @BaptisteC,
instead of importing and using ctypes for the MessageBox, you can access rs.MessageBox
which has the same arguments and return values in rhino python, eg. use this instead of your def Mbox():
import rhinoscriptsyntax as rs
msg = "If UserText already exists, it will be replaced. Continue ?"
result = rs.MessageBox(msg, 4+32, "Your title")
if result == 6:
# do something
Note that i´ve added warning query icon (32) behind your YesNo buttons (4). Two tips: check if the user has canceled the rs.OpenFileName call before opening the file and check if rs.GetString does not return None
or an empty string with zero length if the user canceled the prompt. Otherwise you´re attempting to access None
which would result in an error.
c.
Thank you Clement