FBX export through python

   12082   9   2
User Avatar
Member
93 posts
Joined: 3月 2014
Offline
Hi.

I cannot find how to export to fbx some nodes with python. Is it possible to do in Houdini. I have Indie version.

I only found fbx importing through python: https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=16206&highlight=&sid=0e48aeb092269469b0504485d319a8ca [sidefx.com]
User Avatar
Member
2629 posts
Joined: 6月 2008
Offline
Have you tried the saveToFile () method passing a filename with the .FBX extension?


node.geometry().saveToFile(file_name)


http://www.sidefx.com/docs/houdini14.0/hom/hou/Geometry#saveToFile [sidefx.com]
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
93 posts
Joined: 3月 2014
Offline
Enivob
Have you tried the saveToFile () method passing a filename with the .FBX extension?


node.geometry().saveToFile(file_name)


http://www.sidefx.com/docs/houdini14.0/hom/hou/Geometry#saveToFile [sidefx.com]

Thanks for the reply. I created a sphere object and tried this code:
hou.node('/obj/sphere_object1/sphere1').saveToFile('$HOME/Documents/Exchange/exchange.fbx')

But i got exception:
>>> hou.node('/obj/sphere_object1/sphere1').saveToFile('$HOME/Documents/Exchange/exchange.fbx')
Traceback (most recent call last):
File “<console>”, line 1, in <module>
AttributeError: ‘SopNode’ object has no attribute ‘saveToFile’
User Avatar
Member
76 posts
Joined: 9月 2011
Online
Adding geometry() like:

hou.node('/obj/sphere_object1/sphere1').geometry().saveToFile('$HOME/Documents/Exchange/exchange.fbx')


should fix this
User Avatar
Member
93 posts
Joined: 3月 2014
Offline
jkunz07
Adding geometry() like:

hou.node('/obj/sphere_object1/sphere1').geometry().saveToFile('$HOME/Documents/Exchange/exchange.fbx')


should fix this

Thanks for the answer. The exporter cannot export to fbx. Only obj/dxf/lwo.

And I cannot export a scene with hierarchy to fbx with python. I'll write to SESI for a feature request.
User Avatar
Member
143 posts
Joined: 3月 2014
Offline
+1
User Avatar
Member
93 posts
Joined: 3月 2014
Offline
There is ‘filmboxfbx’ node at ‘out’ context. You can export to fbx normally.
User Avatar
Member
316 posts
Joined:
Offline
You can always wrap the fbx node into a python script:

# create a temporary ROP node
fbx_rop = hou.node('/out').createNode('filmboxfbx')

# set the output path to whereever you want the file to go
fbx_rop.parm('sopoutput').set(“$TEMP/out.fbx”)

# Path to object hierarchy you want to export
obj_path = hou.node('/obj/geo1').path()
fbx_rop.parm('startnode').set(obj_path)

# Now just run the “render” method on the node, and delete the ROP
fbx_rop.render()
fbx_rop.destroy()

User Avatar
Member
26 posts
Joined: 8月 2007
Offline
I get error when I try to createNode() I am using Indie version btw.
The attempted operation failed.
Traceback (most recent call last):
File “hou.session”, line 6, in <module>
File “CPROGRA~1/SIDEEF~1/HOUDIN~1.313/houdini/python2.7libs\houpythonportion.py”, line 541, in decorator
return func(*args, **kwargs)
File “CPROGRA~1/SIDEEF~1/HOUDIN~1.313/houdini/python2.7libs\hou.py”, line 5374, in createNode
return _hou.Node_createNode(*args, **kwargs)
OperationFailed: The attempted operation failed.
This node cannot contain other nodes
User Avatar
Member
1 posts
Joined: 8月 2021
Offline
Enivob
Have you tried the saveToFile () method passing a filename with the .FBX extension?


node.geometry().saveToFile(file_name)


http://www.sidefx.com/docs/houdini14.0/hom/hou/Geometry#saveToFile [www.sidefx.com]


Its worked for me , thanks
  • Quick Links