Page 1 of 1
Looping through selected layers
Posted: Wed Mar 23, 2016 2:30 pm
by lehtiniemi
I tried to look for a way to access selected layers, all I found was CountSelectedLayers(GroupLayer *group). I tried passing it an argument, like so:
Code: Select all
local layerList
moho.document:CountSelectedLayers(layerList)
However, layerList won't contain selected layers after this call. How do I use it or is there some other way?
Re: Looping through selected layers
Posted: Wed Mar 23, 2016 3:33 pm
by synthsin75
CountSelectedLayers does not populate the empty variable. You need to assign it a variable:
local selLayerCount = moho.document:CountSelectedLayers(moho.document)
You can also specify a particular group layer instead of the whole document.
To count through them:
for i=0, moho.document:CountSelectedLayers(moho.document)-1 do
Re: Looping through selected layers
Posted: Wed Mar 23, 2016 3:35 pm
by lehtiniemi
synthsin75 wrote:CountSelectedLayers does not populate the empty variable. You need to assign it a variable:
local selLayerCount = moho.document:CountSelectedLayers(moho.document)
You can also specify a particular group layer instead of the whole document.
To count through them:
for i=0, moho.document:CountSelectedLayers(moho.document)-1 do
Ah, thanks! Hmm but how do I access the selected layers? CountSelectedLayers doesn't tell me which layers are selected.
Re: Looping through selected layers
Posted: Wed Mar 23, 2016 3:39 pm
by synthsin75
lehtiniemi wrote:Ah, thanks! Hmm but how do I access the selected layers? CountSelectedLayers doesn't tell me which layers are selected.
Code: Select all
for i=0, moho.document:CountSelectedLayers(moho.document)-1 do
local layer = moho.document:GetSelectedLayer(i)
Re: Looping through selected layers
Posted: Wed Mar 23, 2016 3:42 pm
by lehtiniemi
synthsin75 wrote:lehtiniemi wrote:Ah, thanks! Hmm but how do I access the selected layers? CountSelectedLayers doesn't tell me which layers are selected.
Code: Select all
for i=0, moho.document:CountSelectedLayers(moho.document)-1 do
local layer = moho.document:GetSelectedLayer(i)
Thanks!!!