Check when a channel is from the camera?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Check when a channel is from the camera?

Post by Víctor Paredes »

Hi, I just received this question and it would be great if you could help me with it:
I'm iterating through all the channels in the document. Is there any way to check whether a channel is a camera channel or not?

Thank you very much!
Image Image Image Image
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
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Check when a channel is from the camera?

Post by synthsin75 »

Code: Select all

	local chanCnt = moho.layer:CountChannels()-1
	local ch = MOHO.MohoLayerChannel:new_local()
	for i=0, chanCnt do
		moho.layer:GetChannelInfo(i, ch)
		if (string.match(ch.name:Buffer(), "(Camera).+")) then
			print(ch.name:Buffer())
		end
	end
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Check when a channel is from the camera?

Post by hayasidist »

or check channelID for one of the global constants

CHANNEL_CAMERA_PANTILT
CHANNEL_CAMERA_ROLL
CHANNEL_CAMERA_TRACK
CHANNEL_CAMERA_ZOOM

e.g.

Code: Select all

for i = 0, numCh - 1 do
		local chInfo = MOHO.MohoLayerChannel:new_local()
		moho.layer:GetChannelInfo(i, chInfo)
		if chInfo.channelID  == CHANNEL_CAMERA_ROLL then ...
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Check when a channel is from the camera?

Post by Víctor Paredes »

Thank you very very much to both! (again!)
I think this is what we were looking for.
Image Image Image Image
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
Post Reply