Check for a group

How can I check if a group having a particular name is present in the scene or not??

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Ok, but you asked about

Ok, but you asked about single group not groups.
The optimized code:

local objGroup = for o in helpers where ( (o.name == "Group01") and (isGroupHead o) ) collect o
if objGroup.count != 0 then...
Goonda's picture

ok....Thanks!! :)

ok....Thanks!! :)

Goonda's picture

Thanks miauu!!! But this is

Thanks miauu!!! But this is working fine only if there is one group of that name. If there are multiple groups of the same name...it is not working. Instead I have tried this:

objgroup = #()
		for o in helpers do
		(
			if o.name == "Group01" then
			(
				append objgroup o
			)
		)
 
		(
			if objgroup.count != 0 then.....
miauu's picture

( groupName =

(	
	groupName = "Group01"
	--	use this
	grp = getNodeByName groupName
	-- or
	-- grp = execute ("$"+groupName)
	if isValidNode grp and isGroupHead grp then
		print "Exst in the scene"
	else
		print "Do not exist in the scene"	
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.