I have been coding in python in grasshopper for about 7 or 8 months now, so I there is plenty I still do not understand. One of the biggest problems I have is getting rhinoscriptsyntax functions (always imported as rs) to do the things they are supposed to do.
For example: I create a brep or a surface component in grasshopper as an input for geometry. I give it list access and type hint GUID.
Then, after making sure the GUID is readable in the script (I always double check, and I save the ID as both a string type and keep the GUID type) I try to use the guid in some rs function, lets say for example rs.GetUserText (to get a value from a key saved in the objects attributes) or rs.SurfaceArea. I input the GUID as I am supposed to, but now in Rhino 7 it returns the error that " ‘NoneType’ object has no attribute ‘GetUserString’, or rs.SurfaceArea simply returns ‘None’ (which means error). I double check the object type to make sure it isnt NoneType… it is always either GUID or str, so I don’t know why rs is telling me it is NoneType.
Can somebody please shine some light on this situation? It has worked many times in the past for me, but all of a sudden doesnt work anymore.
Also, I do not want to program in C#, I would really like to use rhinoscriptsyntax (thats why it is there!)
Thanks for your help!
Hi Brad - it matters whether the GH object is still a GH object or whether it has been baked into the document. It will not have a GUID if it has noit been baked.
The geometry was created in rhino and brought into the script as an input via an empty surface or brep component for which I set the multiple geometries.
Hi Brad - can you post a simple example Rhino and GH file? I am pretty sure this all works right so there must be something simple, I’ll see if I can spot it.
I suspect you need to set the document context to the Active Document before attempting to retrieve the User Text:
Außenlärm Tool.3dm (190.3 KB)
Außenlärm Tool gh script.gh (3.3 KB)
Hi Pascal, sorry for the late response, I was away for a while. I have posted the files here.
The objective of the script is to be able to take in a set of volumes (building rooms) which have one or more sides which are part of the facade. The script is to tell me which side is the facade (based on the object layer defines as fassade), and get me all the GUIDs of the surfaces which make the room enclosure behind that fassade.
Additionally, it should also give me the info of the Fassadenpegel (sound pressure level on the facade) which is saved in the attributes, so that I can do some math with the information and the geometric properties of the surfaces. Line 42 is where the script fails. You can ignore the stuff below line 47, thats just for later when things start working again.
If you can help me figure out what I am doing wrong, I will be so grateful. I keep coming across similar problems working with the GUIDs. Sometimes it works, sometimes it doesnt, and sometimes scripts that work on my PC don’t work on my colleagues computer.