Grasshopper Active Document Name

Is there a way for Grasshopper to get the active file name of the .3dm file you have open?

Elefront has a component that does it.

What do you want to do with that?

I am using it to label parts in multiple files. Part of the label comes from the file name.

There are multiple scripts on this forum. I’m using this:

import rhinoscriptsyntax as rs
import scriptcontext as sc

import Rhino

import os


sc.doc = Rhino.RhinoDoc.ActiveDoc


user = os.environ['USERPROFILE']

document_path = rs.DocumentPath()

rhino_file = (rs.DocumentName())



if folder:
    path = os.environ['USERPROFILE'] + '\\' +  folder

    exists = os.path.exists(path)



if folder and file:
    filepath = os.environ['USERPROFILE'] + '\\' +  folder +'\\' + file

    exists = os.path.exists(filepath)



sc.doc = ghdoc

As you can see it’s sort of just one line of code.

Here’s a definition with a few other scripts:

folder_file_path_rename_python.gh (41.2 KB)

On another note, are you familiar with the Grasshopper Rhino components?

Thanks.

Yes. Why?

You referenced an EleFront component above so I thought maybe you’re unaware of new options…

I actually use both. Elefront still has some features particularly with blocks that the Rhino components don’t. For the most part I do like the Rhino components better as they are able to handle things like baking to particular layer better as you don’t have to make sure the data trees match exactly.

Rhino 8 supports this, look under the “Rhino” tab in “Content”

Wow that is extremely buried. I would have never found that. Thanks. I thought it was odd the Rhino components didn’t have something to do this.