_-LayerStateManager _Export gone in R7?

Hi, it seems that the Export to LAY format functionalilty has been removed from the R7 LayerStateManager. Furthermore, Import now reads from a 3DM, but not from a LAY file.
Is there an alternative way of creating LAY files? I am looking for a solution in Python (RhinoCommon or RhinoScriptSyntax)

I understand that there are no plans of removing LSM, but what we have now is severly crippling its former R6 functionality.

Thank you

Moved to Rhino category.

Hi Axel -

From RH-51674:

The “new” layer state manager imports from 3dm files. There is no longer a need to export some intermediate format.

Just to clarify - since Rhino 7+ neither exports nor imports LAY files, I suppose you are not actually trying to create those intermediate files? Perhaps if you describe the problem you are having, it will be easier for others to offer an alternative?
-wim

Hi Wim,

we use the LSM import/export of LAY files in R6 to perform some sanity checks on the layer states before re-instating them, such as:

  • check if all layers exist
  • check if there are new layers not saved in the LS
  • check if there are empty layers
  • check if there are layers with hidden objects

To do this, we need to get at the state of the layers in the particular layer state before actually restoring it. The vanilla LSM ‘restore’ functionality silently ignores missing or undefined (additional) layers that are not defined in the layer state.

The old LAY import/export allowed us to do this kind of pre-restore error checking, so we could drop out with an error rather than assuming that everything worked all right.

Hi @axa,

The .lay files were abandoned when the information maintained by the Layer State Manager could no longer be represented in simple, comma-delimited text files.

You should still be able to use the Layer State Manager in the say you’re used to. Instead of using .lay files, just keep template .3dm files. The scriptable version of LayerStateManager has an Import option for these.

– Dale

Hi Dale,

thanks for your reply. I’ve played around with template export and LSM 3dm import, but they don’t do what we’re after.

The reason we rely on lay files is that they are very easy to parse (simple Windows ini format), and that we did not find any other way of accessing the saved layer states through Python when we looked into this a few years ago.

So in R6, this is what our Python scripts did to reinstate a layer state:

  1. export layer states to LAY file
  2. parse LAY file with Python’s SafeConfigParser
  3. run checks on all layers saved in the layer state to be reinstated (e.g. layer exists, has objects, has no hidden objects etc)
  4. if any of the checks fails, drop out with an error message and force the user to fix the saved layer state
  5. Otherwise, restore the layer state

In other words: We wrap the LSM Restore functionality to provide the sanity checks that LSM doesn’t have built in.

Consistency is very important for our workflow, and having LSM reinstate a layer state where layers have been deleted, renamed or added without any form of feedback is not good.

I have looked at the RhinoCommon documentation, but it still doesn’t seem to be possible to get at the actual layer states
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_Tables_NamedLayerStateTable.htm

I can do simple things such as

tbl = sc.doc.NamedLayerStates
idx = tbl.FindName(‘TEST1’)

but what do I do with idx? How can I find out all the different layers for layer state ‘TEST1’, and whether they are on or off, what colours they have etc? This seems to be possible only in C++

Your thoughts on this are much appreciated

– Axel

Hi @axa,

There isn’t any SDK access to the actual layer state data. However, it’s not difficult to write .ini files with the same layer info that was written by old versions. Would this be helpful?

– Dale

Hi Dale,

This is very good news. Yes, old-skool .ini files would indeed be very helpful.

Do you plan on making layer state data accessible through RhinoCommon in the future?

Many thanks

– Axel