Ghcomp in Grasshopper Component

I’m trying to implement a basic Telemetry system that logs when a script has run. To make it easily reusable I grab the path of the .gha with ghdoc.Path in a python node. This works well when the script is run in Grasshopper, but nothing is returned when it is run as a Grasshopper component directly in Tekla.

Is there a way to get metadata of the script in this context?

No code

Add a line to the script that e.g. calls out to your server and just bumps a counter.

Hi Niklas,

Try adding SOLVE panel to your python component. When running a definition through Rhino.Inside we need to explicitly specify which components to solve hence we’re only asking the Tekla-related components and the scripting components to solve.

Hope this helps!

It’s not the runnning of the code that is the issue. As a workaround I use the code attached with s as an input to the node. This works when I run the script as a GH Component.

However, I would prefer to use ghdoc.Path instead of the manually written script name to get the full path of the gh-file while also making in easy to copy and paste the node into other scripts. But this doesn’t seem to work when Grasshopper is run in the background through the GH Component.

import datetime
import System.Environment as env

def get_windows_username():
        return env.UserName
    except Exception:
        return "UnknownUser"

def log_user_activity(script_name):
    username = get_windows_username()
    timestamp ="%Y-%m-%d %H:%M:%S")
    log_entry = timestamp + " | " + username + " | " + script_name + "\n"

    # Append the log entry to the text file
    with open(
        "DIRECTORY/script_logs.txt", "a"
    ) as log_file: