Page 1 of 1
add layers to layer comp
Posted: Wed Nov 03, 2021 1:54 am
by davoodice2
hi
I create layer comp and add group layer. but when expose, just groups show. and sub layers will be hide.
how to create layer comp that store current state of layers?
and how to fix group problem?
thanks.
Code: Select all
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true)
comp:AutoAddChildLayers(doc)
....
....
comp:AddLayer(MasterLayer)
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 2:08 am
by synthsin75
Off hand, it looks like you need to pass NULL to AutoAddChildLayers, as per:
https://mohoscripting.com/methods/1273
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 7:34 am
by davoodice2
I did before. default value is NULL too. but I still have problem
Code: Select all
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true,NULL)
comp:AutoAddChildLayers(doc)
....
....
comp:AddLayer(MasterLayer)
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 7:45 am
by synthsin75
davoodice2 wrote: ↑Wed Nov 03, 2021 7:34 am
I did before. default value is NULL too. but I still have problem
Code: Select all
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true,NULL)
comp:AutoAddChildLayers(doc)
....
....
comp:AddLayer(MasterLayer)
I said to pass NULL to AutoAddChildLayers, not SetAutoAddsGroupLayerChildren.
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 7:54 am
by davoodice2
synthsin75 wrote: ↑Wed Nov 03, 2021 7:45 am
davoodice2 wrote: ↑Wed Nov 03, 2021 7:34 am
I did before. default value is NULL too. but I still have problem
Code: Select all
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true,NULL)
comp:AutoAddChildLayers(doc)
....
....
comp:AddLayer(MasterLayer)
I said to pass NULL to AutoAddChildLayers, not SetAutoAddsGroupLayerChildren.
lol. sorry .
Code: Select all
moho.document:PrepUndo(true)
local curLayer = moho.layer
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true)
comp:AutoAddChildLayers(doc,NULL)
again when I use expose to layer comp in moho , all layers will be off
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 7:57 am
by davoodice2
this is all code.
do I write some thing else?
maybe should i used 'MohoDoc:AddLayerComp(comp)' ?!! but what is this command? how to pass comp?
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 8:20 am
by davoodice2
Code: Select all
moho.document:PrepUndo(true)
local curLayer = moho.layer
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true)
local dsfd = comp:AutoAddChildLayers(doc,NULL)
print(tostring(dsfd))
print returns false
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 8:36 am
by davoodice2
Code: Select all
moho.document:PrepUndo(true)
local curLayer = moho.layer
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true)
local dsfd = comp:AutoAddChildLayers(doc,curLayer:Parent())
print(tostring(dsfd))
I frustrated. I can pass every thing for arguments .no error. Just do Nothing. why doc should be one of args? do I access to other docs ?
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 6:04 pm
by synthsin75
You aren't adding any layers to the comp. So there's no group to have its child layers added.
Re: add layers to layer comp
Posted: Wed Nov 03, 2021 10:58 pm
by davoodice2
synthsin75 wrote: ↑Wed Nov 03, 2021 6:04 pm
You aren't adding any layers to the comp. So there's no group to have its child layers added.
I added group. But again dont work. No child added
Re: add layers to layer comp
Posted: Thu Nov 04, 2021 1:51 am
by synthsin75
Code: Select all
local curLayer = moho.layer
local doc = moho.document
local comp = doc:AddLayerCompWithName('DV_solo')
comp:SetAutoAddsGroupLayerChildren(true)
comp:AddLayer(doc:Layer(0))
comp:AutoAddChildLayers(doc, NULL)
SetAutoAddsGroupLayerChildren sets what is allowed for that comp, as per:
https://mohoscripting.com/methods/1272
Then AutoAddChildLayers adds child layers
only if SetAutoAddsGroupLayerChildren allows it, as per:
https://mohoscripting.com/methods/1273
So comp:SetAutoAddsGroupLayerChildren(false) will not allow comp:AutoAddChildLayers(doc, NULL) to add children, but comp:SetAutoAddsGroupLayerChildren(true) will.