Python GH Doc Name

Does any python user can explain why i cant define filename using code as below in a cluster ?

You are using python so you can use the os.path instead of manually extracting the filename:

import os.path as op

filename = op.basename(ghdoc.Path)
filename_no_ext = op.splitext(filename)[0]

print(filename)
print(filename_no_ext)

In the example above filename would be the full filename e.g. test.gh and the filename_no_ext would be the filename without extension e.g. test

That’s because a cluster is a “virtual” Grasshopper document living within the top-level Grasshopper document (or another cluster). You can still output the path/name though:

foo.gh (5.0 KB)

You can probably traverse the cluster hierarchy to get to the top-level Grasshopper document (i.e. if you need the path of this within the cluster), but this all smells a bit like adding needless complexity to me. Why are you clustering the GHPython component in the first place?

1 Like

Because i was thinking to control the font and colour of panel from inside the cluster