Keyframes in swithlayer
Moderators: Víctor Paredes, Belgarath, slowtiger
Keyframes in swithlayer
As in LUA to receive quantity keyframes in swithlayer and their values?
Now I use such decisionBut it is not pleasant to me, and not so correctly works
Code: Select all
local switchLayer = moho:LayerAsSwitch(moho.layer)
local countF=moho.document:EndFrame()
for i = 0, countF - 1 do
local curentF=switchLayer:SwitchValues():GetValue(i)
if (curentF~=switchLayer:SwitchValues():GetValue(i-1) or i==0)then
print (i.." "..switchLayer:SwitchValues():GetValue(i))
end
end
Last edited by maxic on Thu Dec 16, 2004 3:19 am, edited 1 time in total.
How to define quantity of keys, I have understoodIt is impossible to define in what frames there are keys
Code: Select all
local switchLayer = moho:LayerAsSwitch(moho.layer)
print (switchLayer:SwitchValues():CountKeys())
Hello Maxic,
have a look at this script, partly derived from your code.
Unfortunately, it still involves stepping through frame by frame.
It doesn't handle sub-groups within Switch layers, but that would be possible to add without too much extra code
Only tested on a couple of simple files.
Regards, Myles.
have a look at this script, partly derived from your code.
Unfortunately, it still involves stepping through frame by frame.
It doesn't handle sub-groups within Switch layers, but that would be possible to add without too much extra code
Only tested on a couple of simple files.
Regards, Myles.
"Quote me as saying I was mis-quoted."
-- Groucho Marx
-- Groucho Marx
Oh, the usefulness, thanks to you both. It cleared up a few things for me on iterating through layers. I was working on a color picker, and unfortunately I couldn't find an easy way to do it. So I figured I would just scan through the layers in depth order looking for a shape under the mouse. I didn't really think of using the
that you used. I'm still a little dim at this. What I did do
in this test snippet was to temporarily make each of the layers I intend to scan the "current" layer. That way, I could go through the list and still be able to call up existing tools (the shape picker, I think in this case) that work on the current layer from within the scriptwithout modifying them, and just assign it back to the original layer at the end. I was scratching my head about that one when I checked out your code. So, thanks Myles.
Also, I just threw in the UpdateUI() on a hunch, and then discovered when I took it back out to see what happened, Moho crashed. Guess it was a good hunch. I'll have to throw in all that scanning through sublayers, but it helps the start. Wish there was an easier way. I'm sure I could whip something out using an external library, but I'd like to keep the cross-platform thing proper.
--Brian
Code: Select all
local currentLayer = moho.document:Layer(i)
Code: Select all
local originalLayer = moho.layer
for i = moho.document:CountLayers() - 1, 0, -1 do
local mesh = moho:Mesh()
moho:SetSelLayer(moho.document:Layer(i))
moho:UpdateUI()
moho:UpdateSelectedChannels()
local mesh = moho:Mesh()
if (moho.layer:LayerType() == MOHO.LT_VECTOR) then
print ("Layer number:", i+1,"Layer name:",moho.layer:Name(),"Shapes:",mesh:CountShapes())
else
print ("layer", i+1,moho.document:Layer(i):Name())
end
end
moho:SetSelLayer(originalLayer)
moho:UpdateUI()
moho:UpdateSelectedChannels()
Also, I just threw in the UpdateUI() on a hunch, and then discovered when I took it back out to see what happened, Moho crashed. Guess it was a good hunch. I'll have to throw in all that scanning through sublayers, but it helps the start. Wish there was an easier way. I'm sure I could whip something out using an external library, but I'd like to keep the cross-platform thing proper.
--Brian