Skip to content

Commit 47e12cb

Browse files
author
Kacey Coley
committed
Initial commit - added printCamSpecs.py for printing xml data
1 parent 6917c49 commit 47e12cb

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

printCamSpecs.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014 Kacey Coley
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
"""
23+
#printCamSpecs.py
24+
# Kacey Coley
25+
#Creates an xml file, print the position and orientation of houdini cameras
26+
import hou
27+
from lxml import etree
28+
def printCamInfo(cam):
29+
if cam.name():
30+
print "=================="
31+
print "cam name = " + cam.name()
32+
print "tx = " + str(cam.parm('tx').eval())
33+
print "ty = " + str(cam.parm('ty').eval())
34+
print "tz = " + str(cam.parm('tz').eval())
35+
print "=================="
36+
print "rx = " + str(cam.parm('rx').eval())
37+
print "ry = " + str(cam.parm('ry').eval())
38+
print "rz = " + str(cam.parm('rz').eval())
39+
40+
def genCamXML(cam):
41+
42+
camnode = etree.Element(cam.name())
43+
translateX = etree.Element('translateX')
44+
translateY = etree.Element('translateY')
45+
translateZ = etree.Element('translateZ')
46+
rotateX = etree.Element('rotateX')
47+
rotateY = etree.Element('rotateY')
48+
rotateZ = etree.Element('rotateZ')
49+
translateX.text = str(cam.parm('tx').eval())
50+
translateY.text = str(cam.parm('ty').eval())
51+
translateZ.text = str(cam.parm('tz').eval())
52+
rotateX.text = str(cam.parm('rx').eval())
53+
rotateY.text = str(cam.parm('ry').eval())
54+
rotateZ.text = str(cam.parm('rz').eval())
55+
camnode.append(translateX)
56+
camnode.append(translateY)
57+
camnode.append(translateZ)
58+
camnode.append(rotateX)
59+
camnode.append(rotateY)
60+
camnode.append(rotateZ)
61+
s = etree.tostring(camnode, pretty_print=True)
62+
print s
63+
64+
65+
66+
def buildCameraInfo():
67+
root = etree.Element('cam')
68+
nodes = hou.node('/obj')
69+
for child in nodes.children():
70+
if child.type().description() == "Camera":
71+
# printCamInfo(child)
72+
genCamXML(child)
73+
74+
buildCameraInfo()

0 commit comments

Comments
 (0)