Official website only have the document of VB，C#
yes, the Grasshopper SDK website only shows the “Syntax” tab for
Vb.Net. That is because the documention software we used, did not allow to add that tab for Python. Maybe @will can check again if that is now possible. However, it’s not particularly problematic to use the same info also in Python, but it requires to have a solid understanding of the Python rules for accessing members.
Let’s say I’d want to access the AuthorName static property (static attribute in Python):
import Grasshopper print (Grasshopper.CentralSettings.AuthorName)
If you click on it, you will navigate to the page: CentralSettings.AuthorName Property
That one explains it’s a string.
It’s a little more complex when we access instance members.
Let’s take the GH_Component Class:
This one, has mostly instance members. This means that we need to have an instance from somewhere in order to access its members.
One way to get an instance would be this one:
component = ghenv.Component
now, we can manipulate most of its properties (attributes in Python) or methods.
component = ghenv.Component component.Name = "Sample" component.NickName = "Other" component.Description = "This is the new description"
Let’s say we wanted to call the GH_ActiveObject.AddRuntimeMessage Method, which is available because GH_Component derives from GH_ActiveObject as you can see above.
We would have to get that special parameter from the Grasshopper SDK again,
import Grasshopper component = ghenv.Component component.AddRuntimeMessage( Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, "Here is a warning")
I hope this helps,
for Robert McNeel & Associates
ghpythonlib is dynamically generated based on which components you have installed. It doesn’t have a documentation site ATM, but someone might be able to create it. It strictly follows the inputs and outputs of components.
I understand，I will take the official documents as an important reference. Thank you so much，Mr.Giulio.