首页 > 解决方案 > 通过 Python 设置 Vicon 流设备

问题描述

我想使用 python 在 Motionbuilder 2017 中设置 Vicon 流媒体设备。

Vicon 流设备 | 下载页面

from pyfbsdk import*

app = FBApplication()
scene = FBSystem().Scene

# Find the device
viconStreamingDevice = FBCreateObject( 'Browsing/Templates/Devices','Vicon Stream Device', "Vicon Stream Device")

# Import the device to the current file
scene.Devices.append(viconStreamingDevice)

# Execute the Device?
# ...

当我从资产浏览器单击\将设备拖到我的场景中时,它可以正常工作。如果我使用上面的 python 脚本,设备会出现在场景中但不能正常工作。下图显示了当我选择设备时导航器的外观。

Vicon 流设备 | 单击\拖入场景

Vicon 流设备 | Python 脚本

设备信息丢失,“模型绑定:”显示为灰色。此外,场景变得非常脆弱,运行脚本后很快就会崩溃。

点击\拖动和使用上面的python脚本有什么区别?有没有办法使用 python 将 Vicon 流媒体设备导入 Motionbuilder?


下面的答案信息(基于 Paul Boots 的建议)

我最终手动初始化设备并将其连接到我打开的 Vicon Shogun 会话。我将设备设置为离线并保存了文件。下面是我在脚本中用于将设备合并到所需场景的代码。

viconStreamDevice = r"D:\ViconStreamDevice.fbx"
MOptions = FBFbxOptions( True, viconStreamDevice )
app.FileMerge( viconStreamDevice, False, MOptions )

标签: pythonautodeskmotionbuilder

解决方案


在 c++ 工具中添加设备时,我遇到了类似的问题。我的工作是创建一个包含我的设备的模板文件并从 c++ 代码中打开它。您可以使用 python 尝试相同的技巧。


推荐阅读