001 becomes 1 ?

A forum dedicated to George scripting questions
Post Reply
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

001 becomes 1 ?

Post by Lukas »

When you run:

Code: Select all

Shotnumber = 001
#PRINT Shotnumber
It prints "1".

Is there a way to have it print "001"?

(I'm using this to render to the right folders)

Thanks for any help!
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: 001 becomes 1 ?

Post by NathanOtano »

I think you can handle this with the Mads Juul's George Procedures. I was trying to use it but i don't have the time for the moment.

http://wiki.tvpaint.com/index.php?title ... _Mads_Juul" onclick="window.open(this.href);return false;

For now i just start with 1000. Then i d'ont have problems to add 1 each time i need to, keeping the same number of digits.
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
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: 001 becomes 1 ?

Post by Lukas »

Ah, thanks.

I still don't seem to be able to use simply "001" though.

Code: Select all

Shotnumber = 1
string_addZeros(shot_,Shotnumber,3)
Shotnumber = result
#PRINT Shotnumber

FUNCTION string_addZeros(prefix,digit,length)
	LOCAL cur i
	length=length*1
	digit=digit*1
	cur = LEN(digit)
	length=length-1
	FOR i=cur TO length
		prefix=prefix"0"
	END
	prefix =prefix""digit
	result = prefix
	RETURN result
END
This prints: "shot_001"

It's not possible to get "001" back without anything in front of the zeros. The prefix is necessary. :/
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: 001 becomes 1 ?

Post by Lukas »

Ok, I tried something, but got stuck. I use '/' as prefix before the zeros. Because '/' needs to be in the path anyway.

Code: Select all

tv_clipname
clipName = result

string_addZeros('/',clipName,3)
clipName = result

saveDir = projectdir"/"GestionPath""clipName // <---(There's no / in path, because I added it as a prefix)

print saveDir
This works for shot 001, 002, but when I get to '014A' it gets confused. :s
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: 001 becomes 1 ?

Post by Mads Juul »

I think string_addZeros() only works when the string is ending on a digit
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: 001 becomes 1 ?

Post by Lukas »

Ah, thanks Mads!
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: 001 becomes 1 ?

Post by Mads Juul »

Mads Juul wrote:I think string_addZeros() only works when the string is ending on a digit

I change the function so it can take a string with a digit in the middle and add zeros to the digit
for instance
string_addZeros("/","mads1juul",5)
would give this result
"/mads00001juul"

I updated the wiki
http://wiki.tvpaint.fr/index.php?title= ... Clength.29

I also shared a include script with all the George functions here
http://forum.tvpaint.com/viewtopic.php?f=11&t=8653
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: 001 becomes 1 ?

Post by Lukas »

Great Mads! :)
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
Post Reply