Page 1 of 1

Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 16:26
by Yddari
Hello everyone

This is my first post on the forum but I have used it a lot to help me learn TVPaint over the last few months, so thank you! I have searched for the answer to this on the forum but I couldn't find anything. If the topic already exists, I would really appreciate a link so I can read up.

I am wondering if there is a way to copy a layer's structure on to an existing layer and deleting all frames that do not hit an instance head.
I am running some of my layers through a process in a different program to achieve an effect. The other program does not have the exposure information so when I import the layer back into TVPaint, the layer is on 1s.
Here is a visual of the original layer in red, and the output in blue:
Layer_Structure.PNG
Layer_Structure.PNG (6.09 KiB) Viewed 12981 times
The extra frames are unnecessary and are starting to cause problems. Is there a way to delete out the unneeded frames in the blue layer other than manually adjusting the layer?
I have quite a lot of material to process this way so doing it manually is not really an option I want to use. Any insight on this would be really helpful.

Thank you!

Re: Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 17:06
by slowtiger
Look up "recompute instances" in the manual.

Re: Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 18:09
by Yddari
slowtiger wrote: 04 Mar 2019, 17:06 Look up "recompute instances" in the manual.
Thank you for your quick response.

I tried using Recompute Exposures but no matter what number I put in as a threshold it either did nothing or deleted every frame after the first.
The outside process seems to be making some imperceptible (to me) changes on every frame so TVPaint counts them all as different, and for some reason the Recompute Exposures does not pick up on the actual changes in the animation.

Re: Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 18:42
by slowtiger
In that case maybe a script could help - something like "take structure from layer X and apply it to layer Y" - but that's outside my abilities.

Re: Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 19:04
by Yddari
slowtiger wrote: 04 Mar 2019, 18:42 In that case maybe a script could help - something like "take structure from layer X and apply it to layer Y" - but that's outside my abilities.
You're probably right, I suspected that might be the case anyway. I have someone who can script for me so I'll be able to figure something out, but I just wanted to make sure there wasn't something obvious I was missing (I was, it just didn't solve this particular problem)

Thank you so much for the responses and for teaching me about a feature I didn't know about!

Re: Copying layer structure on to an existing layer

Posted: 04 Mar 2019, 23:18
by Svengali
Hey, this might do the trick.
Spoiler : :

Code: Select all

ExposureString = ""

Menu = "=== MatchExposures ===|1. Create master Head&Exposure list from current layer|2. Apply master Head&Exposure list to current layer|Cancel"
tv_ListRequest Menu
parse result Reply d

IF Reply == 0 || Reply == 3
	EXIT
END
tv_UndoOpenStack
IF Reply == 1
	tv_LayerCurrentID
	LayerID = result
	tv_LayerInfo LayerID
	parse result  d d d d d FrameStart FrameEnd d
	FOR i = FrameStart TO FrameEnd
		tv_ExposureInfo i
		FrameInfo = result
		IF CMP(FrameInfo,"head")
			Frame = 1
		ELSE
			Frame = 0
		END
		ExposureString = ExposureString""Frame
	END
	tv_WriteUserString "MatchExposures" "ExpString" ExposureString
	tv_warn "ExposureString = " ExposureString
END

IF Reply == 2
	tv_ReadUserString "MatchExposures" "ExpString" 
	ExposureString = result
	TotalFrames = LEN(ExposureString)
	tv_LayerCurrentID
	LayerID = result
	tv_LayerInfo LayerID
	parse result d d d d d FrameStart FrameEnd d
	FOR i = FrameStart TO FrameEnd
		tv_LayerImage i
		FrameNo = i + 1
		FrameType = CUT(ExposureString,FrameNo,FrameNo)
		IF CMP(FrameType,"1")
			FrameTypeName = "head"
			tv_ImagePush
		ELSE
			FrameTypeName = "exposure"
			tv_ImagePop
			tv_ImagePush
		END
	END
	tv_ImagePop
	tv_LayerRecomputeExposure LayerID FrameStart FrameStop
END
tv_UndoCloseStack
How to use:
Open the Spoiler window, SelectAll and copy the script.
Create a new action button and embed (paste) the script.

For the original layer of the project:
* select the original layer.
* click button and choose menu option 1 (which encodes the head frames/exposure frames information into a string and stores it).

For the processed layer of project:
* process the layer externally using your other software, then reimport it.
* select the imported layer.
* click button and choose menu option 2(which reads the encoded head frame/exposure frame info and applies it to the processed (current) layer.
* result, same heads/exposures as the original layer.

How it works:
* menu option one encodes a string where a 1 represents each head and a 0 represents each exposure.
* menu option two reads the string back.
* If it finds a 1, it pushes the appropriate head frame to an image stack.
* If it finds a 0, it pops a copy of the head frame image from stack to the appropriate exposure frame.
* finally, it processes the layer using the LayerRecomputeExposure operation, turning each duplicate frame into an exposure.

Sven