Page 1 of 1

Collada Export via a Java-Tool

Posted: Fri Aug 23, 2013 4:57 pm
by armandokengne
i wrote this Java Tool to Export WRL-Format to DAE-Format but doesn't work!! Only Blender ist started, and nothing else. And I don't no why. Someone can help me please


Code: Select all

    public class Converter {

        * @param args
       public static void main(String[] args) {
          Runtime rt = Runtime.getRuntime();
          String[] callAndArgs1 = {"C:\\Program Files\\Blender Foundation/Blender/blender.exe", "C:\\Users\\Desktop\\" };
          try {
          Process child = rt.exec(callAndArgs1);
          System.out.println("Blender:: Process exit code is:" +  child.exitValue());
          catch(IOException e) {
           "Blender:: IOException starting process!");
          catch(InterruptedException e) {
           "Blender:: Interrupted waiting for process!");
The Py-Data "":

Code: Select all

    # -*- coding: utf-8 -*-
    import bpy
    bpy.ops.import_scene.x3d(filepath="C:\\3D-Data\\test.wrl", filter_glob="*.wrl", axis_forward='Y', axis_up='Z')

What ist wrong in these Codes? :( :roll:

Another Question: How cann I export via Scripting (Python command) with Blender all drawings (with the same format (WRL)) from a odner together to a new format (DAE) and keep the same original filename (drawingname)? how can i do it? (please, which commands(scripting))



Posted: Fri Aug 23, 2013 6:32 pm
by stiv
String[] callAndArgs1 = {"C:\\Program Files\\Blender Foundation/Blender/blender.exe", "C:\\Users\\Desktop\\" };
Looks like you have the executable name (blender), the script to run (, but no flags or switches to tell blender what to do with that file.

Run 'blender -h' at the command line to see all the options. Hint: -P is your friend.

Posted: Tue Aug 27, 2013 1:29 pm
by armandokengne
Hi Stiv, thank you,
I don't know how can I add a Flag to the Codes. Can you tell me how I cann do it? or give me some example.


Posted: Wed Aug 28, 2013 6:51 am
by stiv
The endgame here is to end up with a complete command like "blender -P"

In python, you can do something like:

Code: Select all

mport os

cmd = 'blender'
flags = ' -P '
script = 'some'
space = '  '

# our final cmd is 'blender -P'
os.system( cmd + space + flags + space + script )
The Java code looks like it take a string array, so likely you can put any necessary flags ( the -P in our case) as a separate string.

geeky notes:

* It looks like java provides an interface to the C function exec() that takes a command and a set of arguments

* real pythoneers would write " ".join( (cmd, flags, script) to get the final command