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

rs.LayerVisible and User Strings

$
0
0

@emilio wrote:

Hi all

There might be something strange with rhinoscriptsyntax.LayerVisible
Calling rs.LayerVisible seems to clear user strings attached to the layer

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def main():
  name = rs.GetString( 'Layer name ?' )
  index = scriptcontext.doc.Layers.FindByFullPath( name, -1 )
  layer = scriptcontext.doc.Layers[ index ]
  print( 'Set user string' )
  ok = layer.SetUserString( 'KEY', 'VALUE' )
  if not ok:
    print( 'SetUserString failed' )
  val = layer.GetUserString( 'KEY' )
  print( 'KEY => %s' % val )
  print( 'Call rs.LayerVisible' )
  rs.LayerVisible( name, False )
  print( 'Get user string' )
  val = layer.GetUserString( 'KEY' )
  print( 'KEY => %s' % val )

main()

( I’ve found that if I use the code from Rhino 5’s rhinoscriptsyntax, that is
Layer.CommitChanges instead of Layer.SetPersistentVisibility, all works fine )

(6.1.18037.13441, 06/02/2018)
Evaluation

Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5834

Latest Images

Trending Articles



Latest Images