Jump to content
Sign in to follow this  
Patrick Winkler

Check if Object is a Container

Recommended Posts


I need to check if a object conatins other objects.

Therefore I wrote this function:

def isContainerObj (obj):
   return vs.FInGroup(obj) != vs.Handle (0) 

It works but vs.FInGroup will return a error Message to the console when the objects is no container.

Has someone a more elegant solution for this.


Edited by Patrick Winkler

Share this post

Link to post

What if you check the type of the object you're querying to see if it's a group or a symbol or another object type that could qualify as a container? That should let you know if it will have any "children".

Still a little clunky, but I'm sure there aren't many other object types that would qualify as a container.

Share this post

Link to post

In addition, if it IS a group/symbol/container object, you may also want to call GetParent on it to see if it's a child of ANOTHER group/symbol/container. (If it returns a Layer, then you're at the outermost container object)

Edited by MarissaF

Share this post

Link to post

You should be able to use the error to your advantage:

def isContainerObj (obj):
	h = vs.FInGroup(obj)
	return false
	return true


Share this post

Link to post

I'm not sure about it but checking the type for vs.HandleContainer () should work accurate.

def isContainerObj (h):
t = type (h)

print (t)

return not type (h) == type (vs.Handle(0)) 

h = vs.FSActLayer ()
print ( isContainerObj (h) )

Maybe some one can confirm this.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  


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.

  • Create New...