GEORGE : get inpoint/outpoint of instance

This section is dedicated to the feature & improvement requests (be sure what you are asking does not exist yet in TVPaint Animation ;) )
Post Reply
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

GEORGE : get inpoint/outpoint of instance

Post by Mads Juul »

I am currently working on a script where it again would be very helpfull to be able set read the inpoiny outpount of an instance on a given layerlayer and frame
Something like

Code: Select all

tv_exposureStats layerID iPosition
and it would return inpoint and outpoint
If there is no instance on the current layer iposition the command will return -1

I made a request with a similar flavour 6 years ago
http://forum.tvpaint.com/viewtopic.php?f=21&t=2620
But I just need to read inpoint and outpoint of a indtance on a give layer on a given iposition I dont need to be able to set the number of exposure. (this would be nice though)

-Mads
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: GEORGE : get inpoint/outpoint of instance

Post by NathanOtano »

I don't know if i understand well what you need, but i think i needed this for some scripts of mine so maybe this function could help (you just have to go to the position you need with another function and remember the position you were if you want to come back) :
Spoiler : :

Code: Select all

#Function Otano_ExposureInfo()
		// Gets a lot of usefull exposure infos
		// Result : position of the named frames on the timeline and total exposure, "None" if outside layer
		// => [CurrentPos] [HeadPos] [TailPos] [Exposure]
		//
		//LOCAL CurrentPos HeadPos TailPos Exposure
		//PARSE result CurrentPos HeadPos TailPos Exposure

		LOCAL CurrentPos HeadPos TailPos Exposure n Start End ifHead
		tv_LayerGetImage
		CurrentPos = result
	
			//Exit if outside layer
	
				tv_LayerInfo currentlayer
				parse result n n n n n Start End n n n
				IF ( (CurrentPos>End) || (CurrentPos<Start) )
					CurrentPos = None
					HeadPos = None
					TailPos = None
					Exposure = None
					result = CurrentPos" "HeadPos" "TailPos" "Exposure
					EXIT
				END
	
			//Searching the Head Position
	
				HeadPos = CurrentPos
				tv_exposureinfo HeadPos
				ifHead = result
	
				WHILE (CMP(ifHead, head)==0)
					HeadPos = HeadPos - 1
					tv_exposureinfo HeadPos
					ifHead = result
				END
	
			//Searching the Tail Position
	
				TailPos = CurrentPos
				tv_exposureinfo TailPos
				ifHead = result
	
				DO 
					TailPos = TailPos + 1 
					tv_exposureinfo TailPos
					ifHead = result
				UNTIL CMP(ifHead, head)==1 || CMP(ifHead, None)==1
			
				TailPos = TailPos - 1
	
		Exposure = TailPos - HeadPos + 1
		result = CurrentPos" "HeadPos" "TailPos" "Exposure
	#END
You get your curent position + the starting and ending position of the instance and its total exposure .
I have to share all that i have done someday.
Last edited by NathanOtano on 12 Nov 2014, 13:30, edited 4 times in total.
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: GEORGE : get inpoint/outpoint of instance

Post by NathanOtano »

Oh and to set the number of exposures on one instance :
Spoiler : :

Code: Select all

#Function Otano_SetOneExposure(NewExposure)
		// Sets exposure of the current instance to NewExposure
		// Result : Returns the exposure after the function and the amount of exposure change.
		// => [ExposureAfter] [ExposureChange]	
		//
		//LOCAL ExposureAfter ExposureChange
		//PARSE result ExposureAfter ExposureChange
 	
		LOCAL CurrentPos HeadPos TailPos Exposure ExposureChange i
		Otano_ExposureInfo()
		PARSE result CurrentPos HeadPos TailPos Exposure
		Otano_GoToHead()
		ExposureChange = NewExposure-Exposure

		IF ( Exposure > NewExposure )
			 FOR i = 1 to ABS(ExposureChange)
			     tv_LayerCut
			 END
		ELSE
			IF ( Exposure < NewExposure )
			tv_ExposureAdd HeadPos ABS(ExposureChange)
			END
		END
		result = NewExposure" "ExposureChange
	#End
And on multiple instances :

Code: Select all

#Function Otano_SetExposure(NewExposure)
		// Selects semi selected instances and sets exposure of one or selected instances to NewExposure
		// Result : Returns the number of modified exposures, the exposure in the selection before and after the function and the amount of total exposure change + the first frame and lenght of the selection before the function
		// => [Iterations] [ExposureChange]
		//
		//LOCAL Iterations ExposureChange
		//PARSE result Iterations ExposureChange
		
		tv_undoopenstack
		LOCAL CurrentFrame StartFrame Length Number CurFrame n SelectTail SelectHead ChangeStart FirstStart FirstLength
		LOCAL Iterations ExposureAfter ExposureChange 
		tv_LayerGetImage
		CurrentFrame=Result
		tv_LayerSelectInfo
		PARSE result StartFrame Length

		IF ((CMP(StartFrame, 0)==1) && (CMP(Length, 1)==1))
			tv_LayerSelect CurrentFrame 1
			tv_LayerSelectInfo
			PARSE result StartFrame Length
		END
		
		FirstStart=StartFrame
		FirstLength=Length
		
		Otano_SelectSemiSelected()
		PARSE result StartFrame Length
		
		Number=Length
		Iterations=0
		ExposureChange=0
			
		DO
			CurFrame=Number+StartFrame-1
			tv_LayerImage CurFrame
			tv_exposureinfo CurFrame
			PARSE result result n n
			IF (CMP(result, "Head")==1) 
				Otano_SetOneExposure(NewExposure)
				PARSE result n Change
				Iterations=Iterations+1
				ExposureChange=ExposureChange+Change
			END
			Number=Number-1
		UNTIL (Number==0)
		
		tv_exposureinfo CurFrame
		PARSE result result n n
		IF (CMP(result, "Exposure")==1) 
			Otano_GoToHead()
			Otano_SetOneExposure(NewExposure)
			PARSE result n Change
			Iterations=Iterations+1
			ExposureChange=ExposureChange+Change
			tv_LayerImage CurFrame
		END
		ExposureAfter = Length + ExposureChange		
		IF (CurrentFrame == FirstLength+FirstStart-1)
			Tv_LayerImage StartFrame+ExposureAfter-1
			Otano_GoToHead()
		ELSE
			Tv_LayerImage StartFrame
		END
		IF (CurrentFrame == FirstStart)
			Tv_LayerImage StartFrame
		END
		
		Tv_LayerSelect StartFrame ExposureAfter
		
		tv_undoclosestack
		result = Iterations" "ExposureChange
	#End
But you'll need those functions to make it work :

Code: Select all

#Function Otano_GoToHead()
		// Go to Instance Head

		#Otano_ExposureInfo()
		LOCAL CurrentPos HeadPos TailPos Exposure
		PARSE result CurrentPos HeadPos TailPos Exposure
		tv_LayerImage HeadPos
	#End	

Code: Select all

#Function Otano_GoToTail()
		// Go to Instance Tail

		#Otano_ExposureInfo()
		LOCAL CurrentPos HeadPos TailPos Exposure
		PARSE result CurrentPos HeadPos TailPos Exposure		
		tv_LayerImage TailPos
	#End

Code: Select all

#Function Otano_SelectSemiSelected()
	// Selects semi-selected Instances
	// Result : Returns the start and lenght of the new selection.
	// => [StartFrame] [Length]
	//
	//LOCAL StartFrame Length
	//PARSE result StartFrame Length

		LOCAL StartFrame Length
		tv_LayerSelectInfo
		PARSE result StartFrame Length
		tv_LayerImage StartFrame+Length-1
		Otano_GoToTail()
		Tv_LayerGetImage
		Length=Result-StartFrame+1
		tv_LayerImage StartFrame
		Otano_GoToHead()
		Tv_LayerGetImage
		Length=Length+StartFrame-Result
		StartFrame=Result
		Tv_LayerSelect StartFrame Length
		result=StartFrame" "Length
	#End
Last edited by NathanOtano on 12 Nov 2014, 13:28, edited 2 times in total.
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: GEORGE : get inpoint/outpoint of instance

Post by Mads Juul »

Thank you for sharing. But I have made my own functions that do this.
The problem with these user made function is they are slow.
Especially if i want to check a exposure on another layer on another frame than the current.
this is what I want from the a george function ythat look something like

Code: Select all

tv_exposureStats layerID iPosition RETURN inpoint outpoint
But I can see if you also have been forced to write you own george function then the need to be able to find where an instance start and ends is something several users need. and it show I am not the only one who could need a inbuild FAST george command where I can read the ipont and outpoint of an image anywhere in the current clip without changing layer or frame.

Am I clear?
Can you see that I want something else than your function Nathan?
And do you agree You also would like a function like this?
-Mads
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: GEORGE : get inpoint/outpoint of instance

Post by Mads Juul »

So please dont share your scripts here. It clutters up my feature request.

I can do all this. I want inbuild FAST george functions

If you want to share you scripts please do it in the WIKI
And this would be nice if you did
:)
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: GEORGE : get inpoint/outpoint of instance

Post by NathanOtano »

Ok I understand :) and yes i guess i need the same. Faster is better.

Maybe it could help people searching the same thing, so i guess it's not totally unhelpfull. I'll put it on the wiki someday.
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: GEORGE : get inpoint/outpoint of instance

Post by Mads Juul »

NathanOtano wrote:Ok I understand :) and yes i guess i need the same. Faster is better.
I actually found out I can get the inpoint and outpoint from and instance on another layer with
tv_InstanceSetName and tv_InstanceGetName
http://wiki.tvpaint.fr/index.php?title= ... nceSetName
http://wiki.tvpaint.fr/index.php?title= ... nceGetName

Then I can rename a instance to something the other instances before and after is not called
and then check when this name starts and end
and then rename the instance back to the original name

I have found this is the best way for me. But it still is not fast enough :(
Post Reply