Jump to content
Developer Wiki and Function Reference Links Read more... ×
DomC

Set Layer Node

Recommended Posts

Hello

I used my own "set layer" node in past. More recently the default library has a node "Set Layer". Did I understand it wrong or do this node just nothing?

 

# The code in the node of default library
    l = self.Params.layer.value
    o = self.Params.object.value
    
    #script
    layer = vs.GetObject(l) #get layer handle of input layer name 
    obj = vs.GetParent(o)   #get parent of object input (obj = existing layer) 
    vs.SetParent(obj, layer)#set existing layer to new layer that works? 
    
    #outputs
    self.Params.obj.value = o

As I understand, this code set the new layer as the parent of the existing layer. 

I think something like this, would be better, or not?

    #script
    layer = vs.GetObject(l) 
    #obj = vs.GetParent(o)   
    vs.SetParent(o, layer)

 

Test Set Layer.vwx

Edited by DomC

Share this post


Link to post

I think the default content node is missing a check to see if the parent of the object is a Marionette generated group or a layer. In the case of a Marionette created object (for instance a rectangle drawn with the rectangle node) we need to move its parent group to the appropriate layer so that when the network is rerun the object gets replaced. 

  • Like 1

Share this post


Link to post

Hi Marissa

Thank for that quick reply.

Quote

object is a Marionette generated group or a layer.

Aha, now I understand the additional parent check. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×