Page 1 of 1
Select layer and update tool?
Posted: Wed Feb 08, 2023 11:47 pm
by bbrraayyaann
Hello friends, how are you.
I am using the function: ScriptInterface:SetSelLayer(layer) to select a layer, but for example if I am in a bone layer and I select a vector layer, it does not update its corresponding tool, when I select the vector it should change to drawing tool, but it stays in the bone tool for example. Would anyone please know how to do it?
Re: Select layer and update tool?
Posted: Thu Feb 09, 2023 12:53 am
by bbrraayyaann
I was going through scripts and came across this.
I have also tried everything; but I think this is the only solution?
If there is another way let me know.
This script:
https://mohoscripts.com/script/sz_layer ... on_buttons
Code: Select all
-- These are the methods I tried, and none of them updates the tool panel:
-- moho:UpdateUI()
-- moho.view:DrawMe()
-- moho.view:RefreshView()
-- layer:UpdateCurFrame(true)
-- MOHO.Redraw()
-- moho:UpdateSelectedChannels()
-- moho:UpdateBonePointSelection()
-- That's why we have to do some dark magic here instead:
local sacrificialLayer = moho:CreateNewLayer(MOHO.LT_UNKNOWN)
moho:DeleteLayer(sacrificialLayer)
Re: Select layer and update tool?
Posted: Thu Feb 09, 2023 12:57 am
by synthsin75
You might also try jumping to/from frame zero and back. That's another thing that reliably reevaluates the tools window.
Re: Select layer and update tool?
Posted: Thu Feb 09, 2023 1:03 am
by bbrraayyaann
But it works when you use PickGlobalLayer :
Code: Select all
function Pickckckc:OnMouseUp(moho, mouseEvent)
local layer = mouseEvent.view:PickGlobalLayer(mouseEvent.pt)
if layer == nil then return end
if (layer == nil or layer == moho.layer) then
return
end
moho.document:ClearSecondarySelection()
moho:SetSelLayer(layer)
moho:ShowLayerInLayersPalette(layer)
moho:UpdateUI()
end
Re: Select layer and update tool?
Posted: Thu Feb 09, 2023 1:06 am
by bbrraayyaann
synthsin75 wrote: ↑Thu Feb 09, 2023 12:57 am
You might also try jumping to/from frame zero and back. That's another thing that reliably reevaluates the tools window.
Ah, that works well too, thanks