Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Script for Naming Imported STLs

$
0
0

@Jonathan_Hutchinson1 wrote:

I’m trying to do a script to import a number of STLs, and for each one imported to name it as the filename.

browsed = rs.BrowseForFolder(title = "Auto-name Imported Files - Location Picker")
files = rs.OpenFileNames(title = "Auto-name Imported Files - File Picker", folder=browsed)

for filename_iteration in files:
    rs.Command('_-Import ' + filename_iteration + ' _Enter')
    object_guid = rs.GetObject(preselect=True)
    rs.ObjectName(object_guid, filename_iteration)
    rs.Command ('_SelNone ')

The only thing so far thrwing it off is if a filename has a space in it e.g. filepath… 519430376-4 WO.stl

My guess is I need to ‘re-stringify’ each full filepath and loop those instead. So far I am just using the Rhino behaviour of auto selecting something imported to get the imported GUID and then rename it.

For a file called: 519430376-4 WO.stl, the below is reported:

C:\Users\j.hutchinson\Downloads\wetransfer-1ba4b3\519430376-4.3dm not found, unable to open

So after the space it’s assuming a 3dm.

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles