There are four or five layers I need to constantly select (in a project with hundreds), do you know if there's a way to select a layer using a button script in the tool palette?
I'm thinking on this idea:
- Put a "selection1" tag in the layer I want to select
- Have a button in the tool bar which every time I press it, it will select the layer with the "selection1" tag (I could also add a shortcut for it)
Since I have room in my tools palette, I could have several buttons referring to different tags.
Do you think that is possible?
Can a script select a layer?
Moderators: Víctor Paredes, Belgarath, slowtiger
- Víctor Paredes
- Site Admin
- Posts: 5660
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Can a script select a layer?
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
- hayasidist
- Posts: 3518
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Can a script select a layer?
yes -- there's a script interface command ScriptInterface:SetSelLayer(layer, multiSelect, allowDeselect) -- scan the layers for the required tag and use it!..
e.g.
What I'd do is put the above into a file as utility function i.e. hs_sel_by_tag.lua goes in the utility folder
(that core code has been tested -- but it doesn't look to see if there are multiple layers with the same tag -- many ways to address that -- e.g. multi-select; or flag an error; or start from the last selected and move on rather than always start at 0; or .. depends on what you exactly want)
and the guts of the buttons are
local required_tagname = <whatever>
hs_sel_by_tag (moho, required_tagname)
you could (additionally) have a "general" button that asked the user for the required tag
Stan's new script generator should take the strain out of that!
hope that's helpful.
e.g.
Code: Select all
function hs_sel_by_tag (moho, tag)
if not tag then return end
local i = 0
repeat
layer = moho.document:LayerByAbsoluteID(i)
if layer then
i = i + 1
if layer:UserTags() == tag then -- or contains string (e.g. use string.find) or ..
moho:SetSelLayer(layer) -- (or for multiselect (layer,true) and no following "break"
break
end
end
until not layer
return
end
(that core code has been tested -- but it doesn't look to see if there are multiple layers with the same tag -- many ways to address that -- e.g. multi-select; or flag an error; or start from the last selected and move on rather than always start at 0; or .. depends on what you exactly want)
and the guts of the buttons are
local required_tagname = <whatever>
hs_sel_by_tag (moho, required_tagname)
you could (additionally) have a "general" button that asked the user for the required tag
Stan's new script generator should take the strain out of that!
hope that's helpful.
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Can a script select a layer?
Not sure if this is exactly what you have in mind, but try this out, Victor: https://sites.google.com/site/synthsin/ ... ects=0&d=1
With this tool selected, if the first layer tag is a single-character (and available as a shortcut in Moho), hitting that key will select that layer.
It's up to the user to make sure the shortcuts they use are available and not duplicated, and uppercase (shift+key) and lowercase are separate shortcuts.
With this tool selected, if the first layer tag is a single-character (and available as a shortcut in Moho), hitting that key will select that layer.
It's up to the user to make sure the shortcuts they use are available and not duplicated, and uppercase (shift+key) and lowercase are separate shortcuts.
- 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/
- Víctor Paredes
- Site Admin
- Posts: 5660
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: Can a script select a layer?
Thank you very much, hayasidist!hayasidist wrote:yes -- there's a script interface command ScriptInterface:SetSelLayer(layer, multiSelect, allowDeselect) -- scan the layers for the required tag and use it!
(...)
This will be very useful for me.
Wes, this is just fantastic! Thank you very very much! I will start creating all my rigs with this tool in mind!synthsin75 wrote:Not sure if this is exactly what you have in mind, but try this out, Victor: https://sites.google.com/site/synthsin/ ... ects=0&d=1
With this tool selected, if the first layer tag is a single-character (and available as a shortcut in Moho), hitting that key will select that layer.
It's up to the user to make sure the shortcuts they use are available and not duplicated, and uppercase (shift+key) and lowercase are separate shortcuts.
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Can a script select a layer?
I've vastly improved this tool.
Same link: https://sites.google.com/site/synthsin/ ... ects=0&d=1
Full description here: viewtopic.php?f=12&t=32641
Same link: https://sites.google.com/site/synthsin/ ... ects=0&d=1
Full description here: viewtopic.php?f=12&t=32641
- 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: Can a script select a layer?
I was just thinking there should be an easier way to select deeply nested layers, like an editable/clickable list of frequently selected layers or something like that. Then I remembered this thread.
Will give the script a try today. Sounds like it might do what I need.
Will give the script a try today. Sounds like it might do what I need.
D.R. Greenlaw
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Can a script select a layer?
Hopefully it's a bit faster than opening and scrolling through a list of layers.
- 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/