Jump to content

Mplay and python


Pancho

Recommended Posts

I can't find anything in the docs nor the web. I'm so sick of entering manually details into the save dialogs in the mplay window. I actually want to script a shelf button which puts in a filename related to my scene and take, chooses the format, adds a comment and probably some other settings and presses the "save" button in one go. Unfortunately there is no obvious documentation popping in my eye. Can it be done? Or what would be the alternative? In a production is feels so clumsy to enter these parameters over and over again.

Cheers
Tom

Link to comment
Share on other sites

Thanks for the link, but as far as I can tell, this is about the flipbook. Mplay seems to be the external file that Houdini runs to display the frames. And I would need to get hold off the code which is needed to alter Mplays windows and parameters.

Link to comment
Share on other sites

Mplay's dev kit is pretty limited as far as I know, but I've created a few custom flipbooks in the past using python and mplay.

This is will do the bulk of what you want to achieve. Essentially you want to write files to either to disk or directly into mplay - this will do that.

Link to comment
Share on other sites

I've done something similar a while ago if I understand you right, with flipbooks

 

import os

#Choose the camera

all_cams = hou.node("/obj").glob("cam*")

desktop = hou.ui.curDesktop()
scene_viewer = desktop.paneTabOfType(hou.paneTabType.SceneViewer)
viewport = scene_viewer.curViewport()

if len(all_cams)>0:
    camera = hou.ui.selectNode(node_type_filter = hou.nodeTypeFilter.ObjCamera)
    cam = hou.node(camera)
else:
    name = hou.ui.readInput("Enter camera name :", buttons=("OK", "Cancel"))
    cam = hou.node("/obj").createNode("cam", name[1])
    hou.GeometryViewport.saveViewToCamera(viewport, cam)
    
#Create comments
    
group = cam.parmTemplateGroup()

if group.find("vcomment") > -1:
    group.remove(group.find("vcomment"))
    group.remove(group.findFolder("Comment"))

folder = hou.FolderParmTemplate("OpenGL View", "Comment")
parm = hou.StringParmTemplate("vcomment", "Comment", 1)
parm.setTags({"editor": "1"})
folder.addParmTemplate(parm)
group.append(folder)
cam.setParmTemplateGroup(group)

commentCount = hou.ui.readInput("Number of Comments :", buttons=("Ok", "Cancel"))
print int(commentCount[1])
comments = []
for i in range(0, int(commentCount[1])):
    comments.append("Comment" + "_" + str(i))
    
commentInput = hou.ui.readMultiInput("Enter your Comment :", comments, buttons=("Ok", "Cancel"))  
comment = "\n".join(commentInput[1])
cam.parm("vcomment").set(comment)

hou.GeometryViewport.setCamera(viewport, cam)

#Create the flipbook

cur_desktop = hou.ui.curDesktop()
scene = cur_desktop.paneTabOfType(hou.paneTabType.SceneViewer)
flipbook_options = scene.flipbookSettings().stash()

flipbook_options.outputToMPlay(True)
flipbook_options.useResolution(False)
flipbook_options.cropOutMaskOverlay(False)
flipbook_options.frameRange(hou.playbar.timelineRange())
flipbook_options.outputZoom(100)

 

Maybe it can help..

 

Cheers,

Link to comment
Share on other sites

Been having a go at this with shadesoforange

Using xml to append a menu you can get to a place where you can execute python, but there is an issue when trying to use hou.ui, it states that 'module' object has no attribute 'ui',  hou.qt throws the same error.

You can get access to the hou module without having to import, so it is working, you are able to do things like write out hou.getenv('foo') to a file.

What might be the limitation on accessing hou.ui here?

Also, there is seemingly no way to get access to the current mplay session for writing it out or doing stuff, as it is dependent on a hou.SceneViewer object to actually stash the settings.

Going to write to sesi with these findings, does anyone know of any options here we might be missing?

<?xml version="1.0" encoding="UTF-8"?>

<mainMenu>
    <menuBar>

    <subMenu id = "extra_menu">
    <modifyItem><insertAfter>window_menu</insertAfter></modifyItem>
    <label>Extra</label>

            <scriptItem id="export_sequence">
                <label>Export Sequence</label>
        <scriptCode><![CDATA[
hou.ui.selectFile()
]]>
        </scriptCode>
            </scriptItem>

  </subMenu>

    </menuBar>

</mainMenu>

 

Link to comment
Share on other sites

  • 7 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...