Count Layer issue

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
dkwroot
Posts: 677
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Count Layer issue

Post 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.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Count Layer issue

Post 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!?
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Count Layer issue

Post 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.
dkwroot
Posts: 677
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Count Layer issue

Post by dkwroot »

Thanks guys, this helped a lot.
Post Reply