woodenduck Posted May 1, 2017 Share Posted May 1, 2017 Hi, I have created a geo node who's world transforms are matched to those of the current viewport, using the following Python. import toolutils viewer = toolutils.sceneViewer() viewport = viewer.curViewport() xform = viewport.viewTransform() obj = hou.node("/obj").createNode("geo") obj.setWorldTransform(xform) So far so good... Now I want to set these values with Python parameter expressions on the object so that the transforms are updated when the viewport is tumbled. The problem I'm facing is when I try to access the individual components of the xform matrix to set as the object parm I get "the Matrix4 object is not iterable"...??? Any ideas how I can dynamically link an objects transforms to those of the viewport? Thanks for any tips, WD Quote Link to comment Share on other sites More sharing options...
cosku Posted May 1, 2017 Share Posted May 1, 2017 You'd need to extract translation & rotation from that matrix, Like, for tx: import toolutils viewer = toolutils.sceneViewer() viewport = viewer.curViewport() xform = viewport.viewTransform() return xform.extractTranslates()[0] for ry: import toolutils viewer = toolutils.sceneViewer() viewport = viewer.curViewport() xform = viewport.viewTransform() return xform.extractRotates()[1] etc. 1 Quote Link to comment Share on other sites More sharing options...
woodenduck Posted May 1, 2017 Author Share Posted May 1, 2017 Thanks @cosku, This is exactly what I was looking for. Cheers! WD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.