Jump to content
relume

change layer assignment of an object | moving object to an other layer?

Recommended Posts

Hello

 

I am wondering if there is an easy assignment command for objects to change layers as it is for classes (vs.setClass or vs.setClassN). Can it be true, that this should be only possible by duplicating the object first (by vs.CreateDuplicateObject) and thereafter deleting the original? In the VW GUI info-Palette with the appropriate pop-list the task seems more as an reasignment than a duplication (or a hidden cut/past operation).

 

Many thanks in advance and best regrads,

 

Share this post


Link to post

Hi,

Can you please put up the whole script start to finish? I've seen various posts on this but I can't customise SetParent to work. I'd be super grateful if you can do this! Thanks

Share this post


Link to post

Hello

 

please find two scripts that I have created as part of libs:

 

# use		:	assigns a new layer to object 

def object_layer_assign(vObject_Handle, vLayer_Destination_Name):
	
	vLayer_Destination_Handle = vs.GetLayerByName(vLayer_Destination_Name)
	if vLayer_Destination_Handle == None:
		vLayer_Actual_Handle = vs.ActLayer()
		vLayer_Actual_Name = vs.GetLName(vLayer_Actual_Handle)
		vs.Layer(vLayer_Destination_Name)
		vLayer_Destination_Handle = vs.ActLayer()
		vs.Layer(vLayer_Actual_Name)
	
	vs.SetParent(vObject_Handle, vLayer_Destination_Handle)
	

 

and :

 

# use		:	assigns a new layer to objects selected by criteria

def object_layer_assign_criteria(vSelection_Criteria, vLayer_Destination_Name):
	
	vLayer_Destination_Handle = vs.GetLayerByName(vLayer_Destination_Name)
	if vLayer_Destination_Handle == None:
		vLayer_Actual_Handle = vs.ActLayer()
		vLayer_Actual_Name = vs.GetLName(vLayer_Actual_Handle)
		vs.Layer(vLayer_Destination_Name)
		vLayer_Destination_Handle = vs.ActLayer()
		vs.Layer(vLayer_Actual_Name)
	
	def object_layer_assign_iterator(vObject_Handle):
		vs.SetParent(vObject_Handle, vLayer_Destination_Handle)
	
	vs.ForEachObject(object_layer_assign_iterator, vSelection_Criteria)
	

I hope they will be to your help,

 

best regards,

 

 

 

 

Share this post


Link to post

Thank you! I'm new to scripting so I'll try work with this. Might need to repost for some help later. Cheers.

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.

×