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 / continuous execution on python
  RSS 2.0 ATOM  

continuous execution on python
Rate this thread
 
63336
 
Permlink of this thread  
avatar
  • volvic
  • Posted: 06 January 2012 04:58 AM
  • Total Posts: 14
  • Joined: 27 November 2008 07:01 PM

Hi,

I would like to execute continuously some piece of code,

here is a dummy example:

from pyfbsdk import *
import time

myModel 
FBFindModelByName('Cube')
myModel.Selected  True     
  
for n in range(110):
    
myModel.Translation =  FBVector3d (n,2,2)
    
time.sleep(1)


I want the cube to move every second, instead when I execute it, the navigator will freeze for 10 second and then the cube will jump to final position.

How can I do this?

Thank you!

V’



Replies: 0
avatar
  • Ollie_D
  • Posted: 17 January 2012 07:33 PM

Motionbuilder is not multi threaded in that way.  In fact it is not multi threaded at all.  When the script is running, the application will lock up till completion.

The best way to achieve what you are after would be to use a relation constraint.  Use the system time node as the input.  Convert it into seconds and use that to trigger moving the object.



Replies: 4
/img/forum/dark/default_avatar.png

Hi,

tnx for the reply Olie. I gave the previous example just as an example, what I want to do is actually communicating by UDP with another soft.

Now using this method, as there is no global variable if I am not wrong, I need to each time to open a port, read and close the port (I tested it and I cannot run it faster than 15-20Hz).

Do you see any way to do it better?

Cheers

S’

Author: volvic

Replied: 18 January 2012 11:31 PM  
/img/forum/dark/default_avatar.png

Hi,

tnx for the reply Olie. I gave the previous example just as an example, what I want to do is actually communicating by UDP with another soft.

Now using this method, as there is no global variable if I am not wrong, I need to each time to open a port, read and close the port (I tested it and I cannot run it faster than 15-20Hz).

Do you see any way to do it better?

Cheers

S’

Author: volvic

Replied: 18 January 2012 11:31 PM  
/img/forum/dark/default_avatar.png

Hi,

tnx for the reply Olie. I gave the previous example just as an example, what I want to do is actually communicating by UDP with another soft.

Now using this method, as there is no global variable if I am not wrong, I need to each time to open a port, read and close the port (I tested it and I cannot run it faster than 15-20Hz).

Do you see any way to do it better?

Cheers

S’

Author: volvic

Replied: 19 January 2012 12:13 AM  
/img/forum/dark/default_avatar.png

Hi,

tnx for the reply Olie. I gave the previous example just as an example, what I want to do is actually communicating by UDP with another soft.

Now using this method, as there is no global variable if I am not wrong, I need to each time to open a port, read and close the port (I tested it and I cannot run it faster than 15-20Hz).

Do you see any way to do it better?

Cheers

S’

Author: volvic

Replied: 19 January 2012 01:56 AM  
avatar
  • _stev_
  • Posted: 19 January 2012 08:57 AM

You could instead send the command directly to motionbuilder via “telnetlib”.  Part of this blog post shows how to do it:

http://www.chrisevans3d.com/pub_blog/?p=8

I have used this technique myself a few times and it does work without interrupting Motionbuilder.

Stev



Replies: 0
avatar
  • Ollie_D
  • Posted: 22 January 2012 12:29 PM

Hi,

tnx for the reply Olie. I gave the previous example just as an example, what I want to do is actually communicating by UDP with another soft.

Now using this method, as there is no global variable if I am not wrong, I need to each time to open a port, read and close the port (I tested it and I cannot run it faster than 15-20Hz).

Do you see any way to do it better?

Cheers

S’

Sounds like what you need is a custom device.  Devices allow motionbuilder to communicate with outside sources.  They will operate in realtime, at least up to 60hz.  You could set one up to communicate with your other software.

This is getting into the realms of plugin development though.  Not sure if you have time or money for that kind of thing.



Replies: 0