triggering indigo render from Blender

Announcements, requests and support regarding the Blender Indigo export script
Arnaud0
Posts: 7
Joined: Tue Nov 07, 2006 1:50 pm

triggering indigo render from Blender

Post by Arnaud0 » Thu Nov 30, 2006 4:31 pm

Hi all:

following up on the idea of rewriting the inifile.txt
http://www.indigorenderer.com/joomla/fo ... .php?t=636
it seemed to me that the logical continuation would be that the script should also be able to launch Indigo renderer (new toggle to authorize).
To launch Indigo, I tried the following code:

Code: Select all

    commandRender='C:/indigo/indigo.exe'
    os.system(commandRender)
It doesn't work. Specifically, Indigo starts but it throws an error message in its (sub-)console, and a little popup window: Inifile Excep: could not locate the 'localinifile.txt' which of course is in place and is complete.

I suppose that there is a better way to call an outside program, but being a total new-b in python, I don't know. Any idea? I realize that os.system launches a subconsole of the Blender console, and obviously that's not good enough.

Cheers,

Arnaud

Apollux3D
Posts: 19
Joined: Thu Nov 23, 2006 8:51 am
Location: Santo Domingo, Dominican Rep.
Contact:

Post by Apollux3D » Thu Nov 30, 2006 4:41 pm

I´m no expert, but Python must provide some way to navigate trought the hard disk. So a possible solution (in DOS commands) would be:

copy somefile.xml to %INDIGO_PATH%/scripted
cd %INDIGO_PATH%
Indigo /scripted/somefile.xml -o somefile.png
exit

Of course, you need to have %INDIGO_PATH% already set before you start the script.

Arnaud0
Posts: 7
Joined: Tue Nov 07, 2006 1:50 pm

Post by Arnaud0 » Thu Nov 30, 2006 4:48 pm

Thanka Appolux3d.
The problem of copying the file to the indigo folder is resolved for my intent and purposes.
At this point, I can double click on my indigo shortcut, and no matter what I called the xml, it will render the latest scene I exported.
The problem is to let the script launch indigo without my having to even click on the shortcut. I know, it's a bit pointless, but to me it's worth spending 2 or 3hours resolving a problem that can be solved by clicking a menu shortcut in 1 second.

Arnaud
Last edited by Arnaud0 on Fri Dec 01, 2006 5:35 am, edited 1 time in total.

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Thu Nov 30, 2006 4:55 pm

triggering Indigo from blender when you export a project is a feature I've always wanted to see. Just like Max2Indigo does. I guess you should write a temporary XML file and place it by Indigo's executable and then launch it. This way it'll find everything it needs to render. Please let us know if you succeed Arnaud0 :wink: Sorry for not being of much help but my programming skills wouldn't help out much here :wink:
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

Arnaud0
Posts: 7
Joined: Tue Nov 07, 2006 1:50 pm

Post by Arnaud0 » Fri Dec 01, 2006 5:34 am

afecelis: nice to see that someone else wants the same. :D
I will try a couple more things: first I found that there is a module called subrpocess in Python 2.4. BEing an ignoramus (no, full of hope and naive), I'll try the following code tonight... or tomorrow or soon (I have visitors from out of town so I will have even less time than usual in the next few days).
and I noted that os have other options beside os.system("da command"), like spawn... All worth trying.
Anyway, I'll give a shot with the following (again, it assume that you have implemented my little variation noted above: else indigo won't render your scene, but whatever was defined in your inifile.txt):

Code: Select all

try:
    retcode = call("c:\indigo\indigo.exe", shell=True) # play on the direction of the slash...
    if retcode < 0:
        print >>sys.stderr, "Child was terminated by signal", -retcode
    else:
        print >>sys.stderr, "Child returned", retcode
except OSError, e:
    print >>sys.stderr, "Execution failed:", e
I guess part of the game is to learn python and have fun... So my ref. here is the python doc URL (maybe irrelevant but..): http://docs.python.org/lib/node534.html

Cheers.

Arnaud

User avatar
psor
1st Place Winner
Posts: 1295
Joined: Sun Jun 25, 2006 1:25 am
Location: Berlin
Contact:

Post by psor » Fri Dec 01, 2006 6:32 am

Uhm, ... I don't know python either, but I would say call a batch script from
python that looks like this:

Save this text as whatever.bat or whatever.cmd. ;o)

Code: Select all

@echo off

set INDIGOHOME=x:\Indigo\indigo_06

cd /d %INDIGOHOME%

start /b /belownormal Indigo.exe %1

exit
Change the variable INDIGOHOME in the third line to the Indigo directory
then call the batch script in the python script and submit the file you wanna
render ... from my POV this should work. If you've got some questions left,
just ask.

Hope to get you started with this workaround. ^^




take care
psor
"The sleeper must awaken"

User avatar
dougal2
Developer
Posts: 2532
Joined: Wed Nov 15, 2006 8:17 am
Location: South London

just FYI

Post by dougal2 » Sat Dec 02, 2006 12:04 pm

i use combinations of three batch files to start indigo renders.

do_master_and_slave.bat:
starts a network master and slave on the same machine. takes two arguements, the xml file and the name of the local machine

Code: Select all

@Echo off
start /BELOWNORMAL indigo %1 -n m
start /BELOWNORMAL indigo %1 -n s -h %2:7777
do_master.bat:
starts network master on localhost. takes one argument, the xml file

Code: Select all

@Echo off
start /BELOWNORMAL indigo %1 -n m
do_slave.bat:
starts a network slave, takes two arguments, the xml file and the name of the network master

Code: Select all

@Echo off
start /BELOWNORMAL indigo %1 -n s -h %2:7777
for all renders i normally use do_master_and_slave and if the first few minutes of render looks good I can easily add a network slave becuase it's already running in network mode.

User avatar
psor
1st Place Winner
Posts: 1295
Joined: Sun Jun 25, 2006 1:25 am
Location: Berlin
Contact:

Post by psor » Sun Dec 03, 2006 12:12 pm

Ok guys, I did a quick hack of the current exporter script, it works fine but
it's very hackish' ... hehe. This is how it works.

You have to write the Indigo install directory into a file called
IndigoWrapper.conf (example) and save this file to:

.blender\scripts\bpydata\IndigoWrapper.conf

Then use the modified script that you can find here. It has a new toggle,
if enabled the exporter will start Indigo and renders the saved xml.

Just for the curious guys, that's the important code part ...

Code: Select all

#########################################################################
###     LAUNCH INDIGO AND RENDER CURRENT SCENE (WINDOWS ONLY)         ###
###  psor's first steps to Python (executing Indigo per shell script)  ###
#########################################################################

def launchIndigo(filename):
    # get blenders 'bpydata' directory
	datadir=Blender.Get("datadir")
	
	# open 'IndigoWrapper.conf' and read the first line
	f = open(datadir + '/IndigoWrapper.conf', 'r+')
	ic=f.readline()
	f.close()
	
	# create 'IndigoWrapper.cmd' and write two lines of code into it
	f = open(datadir + "\IndigoWrapper.cmd", 'w')
	f.write("cd /d " + ic + "\n")
	f.write("start /b /belownormal Indigo.exe %1\n")
	f.close()
	
	# call external shell script to start Indigo
	cmd=datadir + "\IndigoWrapper.cmd " + filename
	os.system(cmd)


### END OF PSOR ##########################################################
Hope this will help you guys a bit, please remember I'm not a code guru ... :P :D ;)

edit: The execution works only for the 'Export' button NOT for 'Export Anim'.

edit2:Sorry guys, but until now NO 'spaces' are allowed in any path, to Indigo or Blender. I'll check it as fast I can. If somebody has an Idea, speak up! I guess I have to use something like ... 'Path with spaces' ... ;)




take care
psor
Last edited by psor on Sun Dec 03, 2006 1:22 pm, edited 1 time in total.
"The sleeper must awaken"

User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

Post by drBouvierLeduc » Sun Dec 03, 2006 12:52 pm

I get that error :

IOError: [Errno 21] No such file or directory: 'C:\\Program Files\\blender\\.blender\\.blender\\scripts\\bpydata/IndigoWrapper.conf'

(Indigowrapper.conf is in that directory).
Should I get it to work, then thank you for that script !

User avatar
psor
1st Place Winner
Posts: 1295
Joined: Sun Jun 25, 2006 1:25 am
Location: Berlin
Contact:

Post by psor » Sun Dec 03, 2006 1:09 pm

drBouvierLeduc wrote:I get that error :

IOError: [Errno 21] No such file or directory: 'C:\\Program Files\\blender\\.blender\\.blender\\scripts\\bpydata/IndigoWrapper.conf'

(Indigowrapper.conf is in that directory).
Should I get it to work, then thank you for that script !
Hmm, ... I wonder why you do have .blender two times in the path, if I'm not wrong it should be:
C:\\Program Files\\blender\\.blender\\scripts\\bpydata/IndigoWrapper.conf :roll:

And I've checked something, ... until now it's not allowed to have any 'spaces'
in the path that you have to put into the IndigoWrapper.conf file, sorry. ;o)

edit: Arrgh, ... I guess the path to blender shouldn't have any 'spaces'
in the path either ... hmm, have to check that. Sorry for any inconvenience.




take care
psor
"The sleeper must awaken"

User avatar
psor
1st Place Winner
Posts: 1295
Joined: Sun Jun 25, 2006 1:25 am
Location: Berlin
Contact:

Post by psor » Sun Dec 03, 2006 2:31 pm

Ok, ... a quick workaround that is almost the same but will give you a bit
more freedom, at least with 'spaces' in the blender and Indigo path.

Get the updated script here. It will create the shell script on C:\ and will search
there for IndigoWrapper.conf too. I hate to do it this way, but it will work
for now. ;o)

NOTE:If you choose a path for the exported xml file, do NOT use
spaces in that path - it won't work.

Hope to get that fixed ... ^^

Changed 'launchIndigo' function to:

Code: Select all

	# open 'IndigoWrapper.conf' and read the first line
	f = open("C:\IndigoWrapper.conf", "r+")
	ic=f.read()
	f.close()
	
	# create 'IndigoWrapper.cmd' and write two lines of code into it
	f = open("C:\IndigoWrapper.cmd", 'w')
	f.write("cd /d " + ic + "\n")
	f.write("start /b /belownormal Indigo.exe %1\n")
	f.close()
	
	# call external shell script to start Indigo
	cmd="C:\IndigoWrapper.cmd " + filename
	os.system(cmd)



take care
psor
"The sleeper must awaken"

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Sun Dec 03, 2006 4:56 pm

wow psor! this is great! :D Is there a workaround for Linux? :wink:
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

User avatar
psor
1st Place Winner
Posts: 1295
Joined: Sun Jun 25, 2006 1:25 am
Location: Berlin
Contact:

Post by psor » Sun Dec 03, 2006 5:17 pm

afecelis wrote:wow psor! this is great! :D Is there a workaround for Linux? :wink:
Heyho afecelis. :D ;)

Well, I would need more info on how wine works. I haven't used any GUI
on linux since ... erm, ... a loooong time and never used wine. :lol: :twisted: :wink:

edit: Ok, looked up the basics ... maybe I'll find some time
tomorrow, now I'll hit the sack. ;o)




take care
psor
"The sleeper must awaken"

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Sun Dec 03, 2006 7:19 pm

yaaaaaaaaaaaaaaaaaaay!!! :D :D

I tried the script and it reports a python error (an obvious one) saying it can't find the IndigoWrapper.conf in C:. So the script would need to be changed to look for Linux type folders; In my case, I got Indigo at /home/afecelis/Indigo. And to run it I created a simple shell script which I use as an executable and for placing a shortcut on the desktop:

Code: Select all

#!/bin/sh
# Needed to make symlinks/shortcuts work.
# the binaries must run with correct working directory
  cd "/home/afecelis/Indigo"
  wine indigo.exe $*
  exit $? 
so perhaps a Linux version of your new script could point to this sort of executable instead? :wink:

Anyway, thanks for the posibility of the linux version. Meanwhile, sweet dreams. I'll try the beta3 script in Windows.
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Mon Dec 04, 2006 2:56 am

wow psor! just tried it out in windows and works great! :D Pretty neat for a hack! ;)
One question, where is the temp xml file created? EDITED AGAIN: duh! just noticed it's the same as the previous exporter, only with the option to exec Indigo. ;)
Edit: ahhhh! you create a bat file!!! hehehhehehhe clever my dear Watson, clever! :wink:

Couldn't an option to look for indigo's path be added in the exporter GUI? This way all you gotta do is look for your installation folder and the conf file is created as output from this info. And can't the conf file be located inside of indigo's folder?

many thanks Psor, extra cool work.
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

Post Reply
18 posts

Who is online

Users browsing this forum: Google [Bot] and 1 guest