Forum

RhinoScript – Rhino.Command save help

openFileName and saveFileName only let the user pick the particular file names and returns these as string, nothing else. So your approach of letting the user chose the save filename first, then doing the work and then saving the file is perfectly alright.
If you want to work on a stack of files you need to let the user pick several files and save them in an array. Then you ask for the same number of save filenames, and then you can let your script work through each pair of filenames exactly as it does now.

Well, I fixed it, and it works. I'm sure it still needs some help though.

What I really want to do now is to be able to queue up several files so they run in a row. Step files take an inordinate time to import and explode.

I solved the saving issue by saving the file early on, then just simply passing the save command. It's due to poor choice in order on my part. I'm not really sure how vbs works much with the sub routines. The only other scripting I use is ahk, and it remembers everything through each subroutine.

Sub ExplodeVisibleBlockInstances

Const rhInstanceObject = 4096Dim arrBlocks, strBlock

Do
arrBlocks = rhino.ObjectsByType(rhInstanceObject)

IfIsArray(arrBlocks)ThenFor Each strBlock In arrBlocks
Rhino.ExplodeBlockInstance(strBlock)NextEndIf

I'm trying to create a script that opens a user selected step file, allows the user to select where it will be saved (the type should automatically be 3dm) and then continues to open the step file. After it's open the script should also explode the block instances. I took that part, for the most part, from www.rhino3d.com/developer.htm
Although, that didn't work by default, so I tried to kind of recreate it. That's really hard to do for a noob like me though, because I don't know the purpose of some things in the first place. Anyway, it works most of the time. I need to add a purge command in there, but as you can see, it's pretty messy.

I'm having troubles finding info for Rhino.Command. I don't understand why I'm using

Call Rhino.Command("_-Open " & strFile, 0)

top open the file. I don't understand the '&' there. Isn't that for adding two strings? I thought the syntax was just one command after another separated by commas between the parenthesis. And what's up with the '0' at the end? I don't understand what that's for.
Can anyone let me know where to find that sort of info? I'd prefer read about it myself so I can find more help later without bugging anyone.

This script doesn't work yet, but I wanted to share it's progress. I can't get the save name to work. That and I'm missing a purge in there, so the blocks are all exploded, but the last few don't get removed.

Any help is appreciated:

Sub ExplodeVisibleBlockInstances

Const rhInstanceObject = 4096Dim arrBlocks, strBlock

Do
arrBlocks = rhino.ObjectsByType(rhInstanceObject)

IfIsArray(arrBlocks)ThenFor Each strBlock In arrBlocks
Rhino.ExplodeBlockInstance(strBlock)NextEndIf