groups and transparency

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Vercingetorix
Posts: 16
Joined: Tue May 13, 2008 4:18 pm
Location: Australia

groups and transparency

Post 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.
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: groups and transparency

Post 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
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
Post Reply