Page 1 of 1

groups and transparency

Posted: Fri Apr 25, 2014 4:20 pm
by Vercingetorix
Hi
I was just wondering if there is any way to make a group display as transparent in the viewport, I already have transparency ticked in the display options but it only seems to work with single layers not groups.

Re: groups and transparency

Posted: Thu May 01, 2014 12:17 am
by SimplSam
Please have a look at the following code - I think it does what you need. You would need to add this as a Layer Script on the control group layer. All non-group sub-layers will inherit the Opacity properties of the controlling 'parent' group layer. Also enable - 'Allow animated layer effects' property on control parent and child layers if you want the effect on anything other than frame zero.

This same inheritance principal can also be applied to any layer property - with slight script modification.

Code: Select all

--[[> 
	TITLE: SC_LayerInherit (opacity)
	
	SUMMARY: Child layers inherit Opacity / Transparency (fAlpha) from control parent group layer
	
	HISTORY:
		Originally inspired by: DKWROOT's 'Control bones from parent layer' -
				(http://www.lostmarble.com/forum/viewtopic.php?f=12&t=24177)
		
		VERSION: AS10.001.00 - by Sam Cogheil (iTeque.com)
--]]
	
function LayerScript(moho)
	local controlLayer = moho.layer
	if (controlLayer:IsGroupType()) then
		local function SetChildLayer(moho, layer)
			local parentLayer = moho:LayerAsGroup(layer)
			local childLayerCount = parentLayer:CountLayers() 
			for i = 0, childLayerCount - 1 do 
				local childLayer = parentLayer:Layer(i) 
				if (childLayer:IsGroupType()) then
					SetChildLayer(moho, childLayer) 
				else
					if (controlLayer.fAlpha:HasKey(moho.layerFrame)) then -- Avoid creating redundant keyframes
						childLayer.fAlpha:SetValue(moho.layerFrame, controlLayer.fAlpha:GetValue(moho.layerFrame))
					end
				end
			end	
		end   
		SetChildLayer(moho, controlLayer)
	end
end