Page 1 of 1

Count Layer issue

Posted: Sat Jan 16, 2016 10:35 am
by dkwroot
I'm curious if anyone else is having trouble calling the "CountLayers" function.

local LayerNumber = moho.layer:CountLayers()

returns "CountLayers" is nill, despite the fact that there are several child layers to the selected group. This might be a bug, but I need some confirmation here.

--UPDATE--
The CountLayers function fails to work for group or bone layers, but appears to work for switch layers. I'm thinking this is a glitch now.

Re: Count Layer issue

Posted: Sat Jan 16, 2016 12:42 pm
by hayasidist
it's not "moho.layer" -- you need to recast the selected layer as a group

e.g.

Code: Select all

	local ctLayer
	local layer = moho:LayerAsGroup(moho.layer)

	if layer == nil then
--		error
	else
		ctLayer =  layer:CountLayers()
	end
is the glitch that switch "works" as not a group type!?

Re: Count Layer issue

Posted: Sat Jan 16, 2016 8:33 pm
by synthsin75
If you had previously done moho:LayerAsSwitch(moho.layer) it will be a proper group for counting layers. Otherwise the only bug would be switch layers always cast as group layers, which shouldn't harm anything.

Re: Count Layer issue

Posted: Sun Jan 17, 2016 4:34 am
by dkwroot
Thanks guys, this helped a lot.