tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs? Topic is solved

A forum dedicated to George scripting questions
Post Reply
ademir.p
Posts: 10
Joined: 24 May 2022, 14:59

tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by ademir.p »

Hi,
I'm trying to:
  1. add a png file to the image library
  2. add a image support guideline to the project canvas using the newly added png file from the image library
My idea was to use:
  1. tv_libraryimageadd for adding the png file to the image library
  2. tv_guidelineadd for adding the guideline image to the project canvas
However, I'm unable to find any working examples of how to actually use these two commands. It also seems like no one has discussed this on the TVPaint forum. Please correct me if I'm wrong.

The main challenge is getting tv_libraryimageadd to work. The documentation states that these are the parameters to use:

Code: Select all

tv_libraryimageadd "type" "image" "name" iName "parent" iId "source" "file" "path" iPathFile
This is what I have so far:

Code: Select all

tv_libraryimageadd "image" guideline folderID "file" ".../Desktop/guideline.png"
I can't find any documentation on how to get the parent folder id. I would love to see an example.

I did find the tv_libraryimageinfo command:

Code: Select all

tv_libraryimageinfo "id" iId|iPath ["type" "id"|"type"|"name"]
It's supposed to return the id, type or name of and object. However, no matter what I choose to return it will always return:

Code: Select all

folder
So the main question is:
How to retrieve the parent folder ID for the tv_libraryimageadd command or the object id for the tv_libraryimageinfo command.
Windows 11 Pro, 64-bit, 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz, 16 GB RAM
TVPaint Animation 11 Pro WIBU (11.5.3-64 bits)
User avatar
NathanOtano
Posts: 1208
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by NathanOtano »

Hey! I had the same problem adding images from the library to guidelines, at the end I just skipped using the image library and directly imported the image as a guideline from it's path :')

You may have a look at my brush to guide script in this panel : https://forum.tvpaint.com/viewtopic.php?t=15615
I save a brush as file, then add the image from it's path to the guidelines

Code: Select all

//Increment  library image name
tv_readuserstring "brushcount" "actualcount" "0000"
count = result
Writecount = count + 1
tv_writeuserstring "brushcount" "actualcount" Writecount

//Get library root id
//tv_libraryimageinfo "id" "/" "type" "id"
//Root = result

//create folder in library if doesn't exist
    //listcount = 0
    //tv_libraryimagelist "id" root
    //parse result un deux trois quatre cinq six sept huit neuf dix onze douze treize quatorze quinze
    //While ()
    //    tv_libraryimageadd "Type" "folder" "name" "BrushCuts" "parent" root
    //    print result
    //END
//FolderID = result
//tv_libraryimageadd "image" "brush_""count "parent" Root "source" "custombrush"
//BrushCutID = result


filename = "BrushCut_"count

tv_ReadUserString "fileRequest" "fileRequest" 0
PARSE result path
tv_reqfile "'Brush save folder'|"path"|"filename""

IF CMP(result,"cancel")==1
    EXIT
END
path=result

last = LastPos(path,"\")
dir = LeftString(path,last-1)
tv_writeUserString "fileRequest" "fileRequest" 0 dir

SaveFile = path".png"

tv_savebrush SaveFile
BrushFolder=result

tv_projectinfo 
Parse Result a Width Height rest
Width = Width / 2
Height = Height / 2

tv_guidelineadd "image" "path" BrushFolder "x" Width "y" Height

///FUNCTIONS///

FUNCTION LastPos(string,car)
	pos = LEN(string)
	WHILE ((CMP(CHAR(string,pos),car) == 0) && (pos > 0))
		pos = pos-1
	END
	RETURN pos
END

FUNCTION LeftString(string,number)
	LOCAL size
	size = LEN(string)
	IF (number > 0)
		IF (number > size)
			number = size
		END
		RETURN CUT(string,1,number)
	END
	RETURN 0
END
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.
ademir.p
Posts: 10
Joined: 24 May 2022, 14:59

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by ademir.p »

NathanOtano wrote: 02 Oct 2024, 08:59 Hey! I had the same problem adding images from the library to guidelines, at the end I just skipped using the image library and directly imported the image as a guideline from it's path :')

You may have a look at my brush to guide script in this panel : https://forum.tvpaint.com/viewtopic.php?t=15615
I save a brush as file, then add the image from it's path to the guidelines

Code: Select all

//Increment  library image name
tv_readuserstring "brushcount" "actualcount" "0000"
count = result
Writecount = count + 1
tv_writeuserstring "brushcount" "actualcount" Writecount

//Get library root id
//tv_libraryimageinfo "id" "/" "type" "id"
//Root = result

//create folder in library if doesn't exist
    //listcount = 0
    //tv_libraryimagelist "id" root
    //parse result un deux trois quatre cinq six sept huit neuf dix onze douze treize quatorze quinze
    //While ()
    //    tv_libraryimageadd "Type" "folder" "name" "BrushCuts" "parent" root
    //    print result
    //END
//FolderID = result
//tv_libraryimageadd "image" "brush_""count "parent" Root "source" "custombrush"
//BrushCutID = result


filename = "BrushCut_"count

tv_ReadUserString "fileRequest" "fileRequest" 0
PARSE result path
tv_reqfile "'Brush save folder'|"path"|"filename""

IF CMP(result,"cancel")==1
    EXIT
END
path=result

last = LastPos(path,"\")
dir = LeftString(path,last-1)
tv_writeUserString "fileRequest" "fileRequest" 0 dir

SaveFile = path".png"

tv_savebrush SaveFile
BrushFolder=result

tv_projectinfo 
Parse Result a Width Height rest
Width = Width / 2
Height = Height / 2

tv_guidelineadd "image" "path" BrushFolder "x" Width "y" Height

///FUNCTIONS///

FUNCTION LastPos(string,car)
	pos = LEN(string)
	WHILE ((CMP(CHAR(string,pos),car) == 0) && (pos > 0))
		pos = pos-1
	END
	RETURN pos
END

FUNCTION LeftString(string,number)
	LOCAL size
	size = LEN(string)
	IF (number > 0)
		IF (number > size)
			number = size
		END
		RETURN CUT(string,1,number)
	END
	RETURN 0
END
Hi Nathan,
Wouldn't this reference the image instead of embedding it in the TVPaint project file? I'm just thinking that if I share the TVPaint project file with someone else, they would also need the image file. Otherwise, they would see Missing Guideline Dependency errors when opening the TVPaint project file on their end.
Windows 11 Pro, 64-bit, 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz, 16 GB RAM
TVPaint Animation 11 Pro WIBU (11.5.3-64 bits)
User avatar
NathanOtano
Posts: 1208
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by NathanOtano »

Yes this is the problem I had exactly and why I wanted to put it in the image library :')
I guess depending on where you save the dependency in your pipeline it could be fine

I already transmitted all those feedbacks to the team some time ago
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.
ademir.p
Posts: 10
Joined: 24 May 2022, 14:59

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by ademir.p »

Ah okay, I understand. So, we are in the same boat it seems :D

Our situation is that we are sharing the TVPaint project files to some remote artists via FTP. When they download the files and start working, they will import their own image guidelines as local files. When the TVPaint project files are then uploaded via FTP we are experiencing "Missing guideline dependencies" when attempting to open the files.

Our workaround at the moment is having the remote artists doing a few more manual clicks before uploading. This includes importing via the image library instead of from file. I would much rather like to just make a single-push-button in TVPaint that opens up a file dialog that will add the selected image to the library and create a guideline for it.

At the moment it's definitely a tedious process for our artists retrieving and uploading files via FTP, but it's good to know that we are not the first encountering this issue.
Windows 11 Pro, 64-bit, 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz, 16 GB RAM
TVPaint Animation 11 Pro WIBU (11.5.3-64 bits)
ademir.p
Posts: 10
Joined: 24 May 2022, 14:59

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by ademir.p »

Hi Nathan,

Thanks for sharing your code. This is actually what I was looking for in order to get the root id, so thanks for that!

Code: Select all

tv_libraryimageinfo "id" "/" "type" "id"
Next challenge will be how to import the image guidelines from image library instead of from file using:

Code: Select all

tv_guidelineadd "image"
It seems like there are no options to specify that the image import should come from the image library and not from file.
Windows 11 Pro, 64-bit, 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz, 16 GB RAM
TVPaint Animation 11 Pro WIBU (11.5.3-64 bits)
User avatar
NathanOtano
Posts: 1208
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_libraryimageadd and tv_libraryimageinfo - how to retrieve IDs?

Post by NathanOtano »

Glad it helped for part of it :')
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.
Post Reply