Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Starting MotionBuilder from the command line with flags
  RSS 2.0 ATOM  
2 pages: 1.2 first

Starting MotionBuilder from the command line with flags
Rate this thread
 
14899
 
Permlink of this thread  
avatar
  • gon2024
  • Posted: 30 January 2012 10:35 PM

Hello

Do exist any ways/workarounds to tell Motionbuilder to execute a python script given some parameters ?
Because, in the doc -F works for sceneFilePath OR scriptFilePath,
put I think linking to a scriptFilePath without anyway to give it some arguments is useless.

Right now, I managed to write some .py file at runtime in a temp folder with hardcoded behaviour.
If someone had a better idea, i’m all ears !

By the way, -console is no real batch mode, it still open the UI which I really regret.



Replies: 0
avatar

There is nothing directly available in MotionBuilder to pass in parameters via the startup flags, only the full script name, so it either runs or doesn’t run, all or nothing.

-console isn’t suppose to be a batch mode, more just and output window to catch or display output in the OR SDK or Python SDK (if you set it up to output Python), sorry there is no headless MotionBuilder.

~Kristine



KRISTINE MIDDLEMISS | SENIOR DEVELOPER CONSULTANT
AUTODESK DEVELOPER NETWORK Media & Entertainment
http://www.autodesk.com/joinadn

Replies: 0
avatar
  • SuperOli
  • Posted: 31 January 2012 04:23 AM

We had the issue as well here and we considered 2 workarounds:

1- Pass the arguments through the Environment Variables.
2- Pass the arguments through a file.

We chose #1. When we start MotionBuilder in C# using the Process class, we pass our arguments there like so: proc.StartInfo.EnvironmentVariables.Add("Param1", paramValue). So when MotionBuilder starts our script, we read os.getenv("Param1") or something like that.

If we had chosen #2, we would have written our args in a specific file, and read it back in our python script.

Not pretty, but it gets the job done.

-Oli



Replies: 0
avatar
  • gon2024
  • Posted: 31 January 2012 08:36 PM

Thank you for those answers.

Another workaround, only available is the new 2012 versions is to launch motionBuilder and send him code via telnet-pipe.

import telnetlib
host 
telnetlib.Telnet('127.0.0.1'4242)
print(
host.read_until('>>>'5))
print(
host.write(_commandAsString+'\n'))
print(
host.read_until('>>>'5))
host.close()


Replies: 0
2 pages: 1.2 first