how do you create a custom action to set a layergroup to a certain opacity value?

Please use this part to report bugs & errors, ask questions & "How to..."
Post Reply
User avatar
Peter Wassink
Posts: 4437
Joined: 17 Feb 2006, 15:38
Location: Amsterdam
Contact:

how do you create a custom action to set a layergroup to a certain opacity value?

Post by Peter Wassink »

i found this thread:
viewtopic.php?f=34&t=8300&p=74149&hilit ... ity#p74149

it helped me to find the command to set a layer to a certain opacity:
"tv_LayerDensity 80" i've put it in an action and it works great for the active layer

Now i want to make a button that sets all layers of a certain colorgroup to this opacity.
how can i do this?
the scripting in the above thread goes a bit over my head...
Peter Wassink - 2D animator
• PC: Win11/64 Pro - AMD Ryzen 9 5900X 12-Core - 64Gb RAM
• laptop: Win10/64 Pro - i7-4600@2.1 GHz - 16Gb RAM
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: how do you create a custom action to set a layergroup to a certain opacity value?

Post by Svengali »

Peter,
I think this script does what you want with a nicety or two? The same loop-thru-construct could apply other useful processes to all layers.

Code: Select all

Param none
ScriptName = "SetOpacityByGroupColor"

tv_LayerCurrentID
OriginalID = result

tv_ReqNum 0 0 12 "enter groupcolor (0-12)"
GroupColor = result
IF CMP(GroupColor,"Cancel")
	EXIT
END

tv_ReqNum 80 1 100 "enter LayerDensity for GroupColor "GroupColor" "
LayerDensity = result
IF CMP(LayerDensity,"Cancel")
	EXIT
END

LayerNumber = 0
ExitFlag = 1
While ExitFlag == 1
	tv_LayerGetID LayerNumber
	LayerID = result
	IF CMP(LayerID, "none")
		ExitFlag = 0
	ELSE
		tv_LayerSet LayerID
		tv_LayerColor GET LayerID
		ColorIndex = result
		IF ColorIndex == GroupColor
			tv_LayerDensity  LayerDensity
		ELSE
			tv_LayerDensity 100
		END
		LayerNumber = LayerNumber + 1
	END
END
tv_LayerSet OriginalID
tv_warn "Density for All Layers of GroupColor " GroupColor " has been  set to" LayerDensity

sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Peter Wassink
Posts: 4437
Joined: 17 Feb 2006, 15:38
Location: Amsterdam
Contact:

Re: how do you create a custom action to set a layergroup to a certain opacity value?

Post by Peter Wassink »

Thank you very much Sven!

It works perfectly.
and it was very easy to adjust the script so it just sets a preselected group to a preset opacity this is awesome!

makes me think i should be getting into scripting a bit more :D
Peter Wassink - 2D animator
• PC: Win11/64 Pro - AMD Ryzen 9 5900X 12-Core - 64Gb RAM
• laptop: Win10/64 Pro - i7-4600@2.1 GHz - 16Gb RAM
Post Reply