Previous Thread  Next Thread

chat icon Invoking an operator from the command line

damix

Posted: Tue Oct 09, 2012 2:55 pm
Joined: 07 Dec 2011
Posts: 21
Hello everybody. At the end of my export script I wrote:

bpy.ops.export_scene.dmx('INVOKE_DEFAULT')

because I want the file browser to pop up when I click 'Run Script' in the text editor. This works fine. Now I would like the same thing to happen when, instead of using the text editor, I pass the script as a command line argument:

blender -P DmxExporter.py file.blend

The resulting behaviour is quite strange; I would expect Blender to open, with the file browser of my exporter open in a way that I only need to click 'Export' button to actually save the exported scene. Instead, two Blender 3D windows open, seemingly in two different instances of Blender; and the two views are not the same: one looks at the object from the angle used last time the blend file was saved; the other is a Top view. If I switch the order of the arguments:

blender file.blend -P DmxExporter.py

I still get two windows, but the one that used to show the Top view now correctly shows the file browser.

How can I invoke the operator from command line, such that I get a single Blender window showing the export file browser?

Thank you for your help.

Dario
Reply with quote


damix

Posted: Wed Oct 10, 2012 7:51 am
Joined: 07 Dec 2011
Posts: 21
Actually, it seems like reversing the order of the arguments did the trick; I did not notice that it was working correctly because probably I saved the blend file when there were still two windows open after the previous attempt. So yes, the following command launches Blender at the file browser, ready to export file.blend:

blender file.blend -P DmxExporter.py
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group