I can’t seem to get “ExportLayerStates” and “ImportLayerStates” to work!

Greetings!

  I can’t seem to get “ExportLayerStates” and “ImportLayerStates” to work, using the help file examples, can anyone tell me how to make it work?

I am trying to use the RhinoScript VB, to save my Layer states for a Layout a view, the code example doesn’t work. (Note, I have the Rhino VB plugin loaded).
I have the python also, but it does not appear to have the store layer state functions that are as advanced as the old VB stuff.

I have two buttons, each with embedded rhino script, my objective is to save the Layers’ (On or Off) State for this or that Layout view page.

NOTE:
I want it to store the state of all the sub-layers also (basically, just the On or Off) visibility condition.

This is the save layers state button code:

! _NoEcho -_Runscript(
Call Main()
Sub Main()
Dim objPlugIn
On Error Resume Next
Set objPlugIn = Rhino.GetPluginObject(“Rhino Bonus Tools”)
If Err Then
MsgBox Err.Description
Rhino.Print "Err getting plugin obj."
Exit Sub
End If
Call objPlugIn.ExportLayerStates(“C:\OverViewLayerStates.lay”)
End Sub
)

// The above is directly from the help files, but, it never saves the above file to the C drive as:
// “OverviewLayerStates.lay” I cannot find the file even with a search all.
// It appears it just does not make this file.
// The above code runs fine in the debugger and does not show an error.

The next code is the Restore layer state embedded in a restore button again from the help file.

! _NoEcho -_Runscript(
Call Main()
Sub Main()
Dim objPlugIn
On Error Resume Next
Set objPlugIn = Rhino.GetPluginObject(“Rhino Bonus Tools”)
If Err Then
MsgBox Err.Description
Rhino.Print "Err getting plugin obj."
Exit Sub
End If
Call objPlugIn.ImportLayerStates(“C:\OverViewLayerStates.lay”)
End Sub
)
//This code runs, even though there is NO file by that name, which I can find, for it to load, and //it does not show a file call error.

Here is what I want to do, let’s say I have 2 layers, Layer one is ON (and all its sublayers), and Layer two is OFF (some of its sublayers are on, some are off)
I hit the “Save Layer State button” it should save the layers in their current condition, and write that state out to a file.

Then I could turn on let’s say, layer 2, and then hit Restore layer state button (user button), it would load the previously, stored state file, and reset the layers to the last saved condition.
Layer 2 should then turn OFF as it was originally stored.

IF this is do-able in python that is ok also, don’t care if it is vb or python, just want it to work.

Thanks in advance,

Scott

Ahhhh! well it appears that this script will NOT run from within a button, but… It does work IF you call it as a LoadFile from a button…

I was running the script, in the debugger, and it works, I guess it doesn’t work from a button, since it creates
and uses a Tool-Box-Object?

well at any rate, I would LOVE to know why the same script, will not work from within an embedded button…

Scott

Hmm,

It appears that the call:

arrViews = Rhino.NamedViews()
'get an array of view names this doesn’t work, to fill the arrView!!!

does not work from the rhino script debugger either, i have both views and layout views but it always returns a “null” value.

any clues?

Ok, I got it all working!

I Have two buttons, one that saves the status of the layers for “Layout” view that is current.
and each layout view can have its own “layer” saved status.
and saves all those into a .lay file. I even put a cheezy, message box that ask if the current layout view, and layers are the one you want to save!
The restore button, restores the saved layout views choices for the current layout view that you are on!

This is a MASSIVE, MASSIVE time saver, instead of making a separate instance, of the model, and saving/renaming it with its layers set, with dimensions, for layout printing to the machine shop. I can now just have ONE file, with all the individual parts as their own layout and DIMs. I don;t have to propagate a part change, through-out several rhino files now either!!! Man, I am totally lov’n this scripting, it is gong to save me HUGE labor/time cost!

Thanks Rhino!