Execute command line with TVP Topic is solved

A forum dedicated to George scripting questions
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Execute command line with TVP

Post by tokejepsen »

Hey,

Could only find ways of executing a script in TVP from the command line.

Is there a way to execute a command line from within TVP?
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: Execute command line with TVP

Post by ZigOtto »

tokejepsen wrote:...
Is there a way to execute a command line from within TVP?
I'm not sure to understand what's you're exactly looking for,
but you can embed any script command in a custom button,
then assign this button (the embedded command) to a shortkey,

you also have a special command to launch a longer script :

Code: Select all

tv_runscript myscript.grg
(tvpa v10 or up required I think)
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Thanks ZigOtto:)

Don't know why I didn't try batch scripts, but it works!

Code: Select all

tv_runscript "myBatch.bat"
Now the question is how to pass arguments to the batch script. Either of these two work;

Code: Select all

tv_runscript "myBatch.bat" --data key1 value1

Code: Select all

tv_runscript "myBatch.bat --data key1 value1"
If this is not possible, then I'll just write a temporary batch file and execute that.
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

I tried exploring writing a bat file out, but I can't get this to work;

Code: Select all

tv_WriteTextFile "C:/Users/toke.jepsen/Desktop/temp.txt" "Line to write"
On startup TVP asks to the "Write to file", but executing more times and nothing happens. It also doesn't actually write the file.

Has anyone used "tv_WriteTextFile" successfully?
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: Execute command line with TVP

Post by ZigOtto »

afaik, (tv_WriteUserString and tv_ReadUserString work as expected,
they are used in many scripts from the content sharing section,
to store and retrieve tvpaint data (text or values) from one session to the other, these 2 commands require "Section" and "Argument" parameters, to indicate precisely where to write/read the text file within the config file,

Code: Select all

tv_WriteUserString  section line text
Writes a character string to the current configuration file. The section argument is the name of the section, and the line argument is the name of the line in which the text string is to be written. These arguments must be surrounded by double quotes. This command is used to store variables between two working sessions using George and TVPaint and to read them using tv_ReadUserString. (However take care not to put too many character strings into the configuration file).
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Thanks ZigOtto:)

I've used

Code: Select all

tv_WriteUserString
and

Code: Select all

tv_ReadUserString
successfully. The problem is writing out a file to disk with

Code: Select all

tv_WriteTextFile
.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: Execute command line with TVP

Post by Mads Juul »

tokejepsen wrote:I tried exploring writing a bat file out, but I can't get this to work;

Code: Select all

tv_WriteTextFile "C:/Users/toke.jepsen/Desktop/temp.txt" "Line to write"
On startup TVP asks to the "Write to file", but executing more times and nothing happens. It also doesn't actually write the file.

Has anyone used "tv_WriteTextFile" successfully?

You forgot "Create"

This code will work

Code: Select all

Param none
tv_writetextfile "Create" "C:\test\test.txt" "Hello World"
read about it here
http://wiki.tvpaint.fr/index.php?title=Tv_WriteTextFile" onclick="window.open(this.href);return false;

I dont think there is a way to execute Command line directly in TVPaint. Is there Developers?
It could be handy I would use it.
I have a small script in Python than looks in a folder. Then I can write a text file from TVpaint in this folder the python script will notice and execute the command
http://timgolden.me.uk/python/win32_how ... anges.html" onclick="window.open(this.href);return false;
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Thank you Mads:)

That worked a treat!

So what I'm having a some trouble with now, is how to write double quotation marks. The current workflow is to write a temporary bat file, and run it. This way I can add arguments to the bat file and "tv_runscript" to run the bat file.
I'm passing in the original bat file, I want to execute with some arguments from a user string, and the destination path for the temporary bat file;

Code: Select all

tv_ReadUserString pyblish script
PARSE result pyblishScript
tv_ReadUserString pyblish path
PARSE result pyblishPath
script = pyblishScript' --data key1 value1'
tv_WriteTextFile "Create" '"'pyblishPath'"' script
tv_runscript pyblishPath
tv_WriteTextFile "Remove" '"'pyblishPath'"'
What I can't seem to get working is how to write double quotation marks around the path to the original bat file. Anyone got an insight on this?
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: Execute command line with TVP

Post by Mads Juul »

Pretty clever to run a .bat file with tv_runScript I didn't knoe it could do this . I only thought it would rum George Scripts. Maybe it also could run Python Scripts?

tokejepsen wrote: What I can't seem to get working is how to write double quotation marks around the path to the original bat file. Anyone got an insight on this?
I can't male it work either :( . Maybe the developers can help?
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Maybe it also could run Python Scripts?
You probably could, else you could run a bat file that runs the python script:)
Svengali
Posts: 1558
Joined: 28 Dec 2006, 10:08

Re: Execute command line with TVP

Post by Svengali »

tokejepsen wrote:

Code: Select all

tv_ReadUserString pyblish script
PARSE result pyblishScript
tv_ReadUserString pyblish path
PARSE result pyblishPath
script = pyblishScript' --data key1 value1'
tv_WriteTextFile "Create" '"'pyblishPath'"' script
tv_runscript pyblishPath
tv_WriteTextFile "Remove" '"'pyblishPath'"'
What I can't seem to get working is how to write double quotation marks around the path to the original bat file. Anyone got an insight on this?
try first setting quotes around path and filename in a variable:

Code: Select all

PathFileName = CONCAT(pyblishPath,pyblishScript)
PathFileName = '"'PathFileName'"'  // apply quotes here
tv_warn PathFileName   // check that the path and filename are contained in quotes as you want it...
tv_WriteTextFile "Create" PathFileName Script
I think tv_WriteTextFile doesn't accept inserting the needed quotes while executing the command.

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Thanks Sven:)

I tried setting the quotation marks before, but it just seems to ignore it when writing to disk. Here a test case;

Code: Select all

script = 'somethingInQuotes'
script = '"'script'"'
PRINT script
tv_WriteTextFile "Create" "C:\Users\toke.jepsen\Desktop\temp.txt" script
It prints the quotation marks, but TVP doesn't write the quotation marks to the text file.
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: Execute command line with TVP

Post by Mike »

Try this ?

Code: Select all

script = 'xxx bla"bla"bla xx'
PRINT script
tv_WriteTextFile "Create" "C:\Users\toke.jepsen\Desktop\temp.txt" script
But I think it can be problematic if you want to write single-quote AND double-quotes with the same command.
TVPaint Team
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

Thanks Mike:)

Your code works, but the problem is when you have the quotation marks at the beginning of the string;

Code: Select all

script = '"bla" bla xx'
PRINT script
tv_WriteTextFile "Create" "C:\Users\toke.jepsen\Desktop\temp.txt" script
tokejepsen
Posts: 19
Joined: 20 Aug 2015, 12:41

Re: Execute command line with TVP

Post by tokejepsen »

More to this. The problem actually seems to be with whitespace before or after the quotation marks.

Code: Select all

script = 'xxx bla "bla"bla xx'
PRINT script
tv_WriteTextFile "Create" "C:\Users\toke.jepsen\Desktop\temp.txt" script
Post Reply