Create new layercomp from toolscript
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 32
- Joined: Tue Mar 24, 2015 3:04 pm
Create new layercomp from toolscript
For our pipeline, Im writing a tool script that automatically generates layercomps.
However, I am not able to create a new layercomp through scripting.
I'm using:
moho.document:AddLayerComp()
But I need to refer to a LayerComp object. How to create a new one?
Thanks in advance!
Jeroen
However, I am not able to create a new layercomp through scripting.
I'm using:
moho.document:AddLayerComp()
But I need to refer to a LayerComp object. How to create a new one?
Thanks in advance!
Jeroen
Re: Create new layercomp from toolscript
I think the only way to create a layercomp is the Layers panel in Anime Studio UI...
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
-
- Posts: 32
- Joined: Tue Mar 24, 2015 3:04 pm
Re: Create new layercomp from toolscript
Thanks Stan, I suppose there must be a way, as the function is there:
moho.document:AddLayerComp()
When I call this function, the lua console outputs:
argument 2 is no object: 'LayerComp expected. So my guess was:
local comp = MOHO.LayerComp:new_local()
moho.document:AddLayerComp(comp)
But the LayerComp Class has no function called 'new_local()'. I'm sure it must be possible, I just cannot find it in the reference, the only place with documentation about layercomp scripting is aslua.com
moho.document:AddLayerComp()
When I call this function, the lua console outputs:
argument 2 is no object: 'LayerComp expected. So my guess was:
local comp = MOHO.LayerComp:new_local()
moho.document:AddLayerComp(comp)
But the LayerComp Class has no function called 'new_local()'. I'm sure it must be possible, I just cannot find it in the reference, the only place with documentation about layercomp scripting is aslua.com
- synthsin75
- Posts: 9973
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Create new layercomp from toolscript
Yeah, I tried that. There seems to be a bug in the layer comp script access. It does actually do something, but you can't see it until you save/reopen the file. You have to copy an existing comp, since we can't create a new one. And closing the file after running this will crash AS every time:
It also renames 2 comps, so I assume the crash is related to AS somehow confusing memory spaces or something. I'll report the bug.
Code: Select all
local doc = moho.document
local name = LM.String:new_local()
name:Set('new comp')
local id = doc:CountLayerComps()-1
local comp = doc:GetLayerComp(id)
doc:AddLayerComp(comp)
doc:GetLayerComp(id+1):SetName(name)
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- hayasidist
- Posts: 3522
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Create new layercomp from toolscript
ha! beat me to it... I'd just done the same - duplicate the last -- and *crash* with all the layer comps named the same as the one I'd just created .. I'd been looking for a bug in my code... kinda glad to see it wasn't me...
Wes, If you're logging a bug - could you ask for a :new() and :new_local() as well please!! Ta!!
Wes, If you're logging a bug - could you ask for a :new() and :new_local() as well please!! Ta!!
- synthsin75
- Posts: 9973
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Create new layercomp from toolscript
Yeah, that's the first thing I mentioned in the bug report, Paul.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Create new layercomp from toolscript
Hi Wes,
Was the bug resolved in Moho 12?
Was the bug resolved in Moho 12?
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
- synthsin75
- Posts: 9973
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Create new layercomp from toolscript
Yes, I tested it when it was fixed.Stan wrote:Hi Wes,
Was the bug resolved in Moho 12?
moho.document:AddLayerCompWithName("someName")
moho:UpdateUI()
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Create new layercomp from toolscript
Great, thank you Wes!
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho