add layers to layer comp

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

add layers to layer comp

Post 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)
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 10153
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: add layers to layer comp

Post by synthsin75 »

Off hand, it looks like you need to pass NULL to AutoAddChildLayers, as per: https://mohoscripting.com/methods/1273
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post by davoodice2 »

synthsin75 wrote: Wed Nov 03, 2021 2:08 am Off hand, it looks like you need to pass NULL to AutoAddChildLayers, as per: https://mohoscripting.com/methods/1273
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)
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 10153
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: add layers to layer comp

Post 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.
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post 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
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post by davoodice2 »

Image

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?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post 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
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post 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 ?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 10153
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: add layers to layer comp

Post by synthsin75 »

You aren't adding any layers to the comp. So there's no group to have its child layers added.
User avatar
davoodice2
Posts: 387
Joined: Tue Jun 15, 2021 1:14 pm

Re: add layers to layer comp

Post 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
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 10153
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: add layers to layer comp

Post 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.
Post Reply