Exemple #1
0
 def run(self):
     import toolutils
     import soptoolutils
     activepane = toolutils.activePane(kwargs)
     if activepane.type() == hou.paneTabType.SceneViewer:
         # Get the current context.
         sceneviewer = toolutils.sceneViewer()
         # Create a SOP container.
         container = soptoolutils.createSopNodeContainer(
             sceneviewer, "curve_object1")
         # Create the curve.
         newnode = soptoolutils.createSopNodeGenerator(
             container, "curve", None)
         # Turn on the highlight flag so we see the SOPs selected output.
         newnode.setHighlightFlag(True)
         if sceneviewer.isCreateInContext():
             newnode.setCurrent(True, True)
             sceneviewer.enterCurrentNodeState()
             toolutils.homeToSelectionNetworkEditorsFor(newnode)
         else:
             container.setCurrent(True, True)
             toolutils.homeToSelectionNetworkEditorsFor(container)
             activepane.setPwd(container.parent())
             activepane.setCurrentState("objcurve")
     elif activepane.type() == hou.paneTabType.NetworkEditor:
         soptoolutils.genericTool(kwargs, "curve")
     else:
         raise hou.Error("Can't run the tool in the selected pane.")
Exemple #2
0
def techrig_userInput_startBoneEndBone():
    import toolutils
    sViewer = toolutils.sceneViewer()
    startBone = sViewer.selectObjects(
        'Select start bone, press enter to confirm',
        allowed_types=('bone', ),
        allow_multisel=False)
    if (startBone == ()):
        hou.ui.displayMessage('Start bone not selected, terminating tool',
                              severity=hou.severityType.Error)
        return (None, None)
    startBone[0].setSelected(0, True)
    endBone = sViewer.selectObjects('Select end bone, press enter to confirm',
                                    allowed_types=('bone', ),
                                    allow_multisel=False)
    if (endBone == ()):
        hou.ui.displayMessage('End bone not selected, terminating tool',
                              severity=hou.severityType.Error)
        return (None, None)
    if (not techrig_findChildInHierarchy(startBone[0], endBone[0])):
        hou.ui.displayMessage(
            'End bone does not exist in same hierarchy as start bone, terminating tool',
            severity=hou.severityType.Error)
        return (None, None)
    return (startBone[0], endBone[0])
Exemple #3
0
def resetExpr(childNodeName="path_filament/pre_speckspline_TO_H11", param="fx", expr="FS"):
	scene_viewer = toolutils.sceneViewer()
	cwd = scene_viewer.pwd()
	selected = [child for child in cwd.children() if child.isSelected()]	# get selected nodes
	for sel in selected:
		childNode = hou.node(sel.path()+"/"+childNodeName)
		childNode.parm(param).setExpression(expr)
Exemple #4
0
def deleteByName16():
    node = hou.selectedNodes()[0]
    if node:
        selNames = []
        geo = node.geometry()
        viewer = toolutils.sceneViewer()
        viewportSel = viewer.selectGeometry()
        for selection in viewportSel.selections():
            type = selection.selectionType()
            elements = selection.points(
                geo) if type == hou.geometryType.Points else selection.prims(
                    geo)
            grouptype = "point" if type == hou.geometryType.Points else "prims"
            for p in elements:
                name = p.attribValue("name")
                selNames.append("@name=%s" % name)

        selString = ' '.join(list(set(selNames)))

        parent = node.parent()
        pos = node.position()

        blast = parent.createNode("blast")
        blast.setPosition(pos + hou.Vector2(0, -1))
        blast.setInput(0, node)
        blast.parm("group").set(selString)
        blast.parm("negate").set(1)
        blast.setDisplayFlag(1)
        blast.setRenderFlag(1)
        node.setSelected(0)
        blast.setSelected(1)
Exemple #5
0
def run():
        
    #Get GeometrySelection 
    geoSelection = toolutils.sceneViewer().selectGeometry()

    #Selection
    selectionStrings = geoSelection.selectionStrings()

    ####NETWORKPANE STUFF
    #Get Selected Node in Network Pane
    selNode = hou.selectedNodes()

    #Create Split Node
    split = selNode[0].parent().createNode("polycut")
    #Connect
    split.setInput(0, selNode[0],0)

    #Insert Points???
    ##WRONG FORMAT
    split.parm('cutpoints').set(selectionStrings[0])
    split.parm('strategy').set("cut")

    #Arrange Stuff
    split.moveToGoodPosition()
    split.setDisplayFlag(True)
    split.setSelected(1,1,0) 
Exemple #6
0
def setBypass(childNodeName="prep_shell_pt/setPtoBlendBlendP", flag=1):
	scene_viewer = toolutils.sceneViewer()
	cwd = scene_viewer.pwd()
	selected = [child for child in cwd.children() if child.isSelected()]	# get selected nodes
	for sel in selected:
		childNode = hou.node(sel.path()+"/"+childNodeName)
		childNode.bypass(flag)
Exemple #7
0
def resetParm(childNodeName="path_filament/cue_wisp_pts/io_Cue1", param="save_first", value=0):
	scene_viewer = toolutils.sceneViewer()
	cwd = scene_viewer.pwd()
	selected = [child for child in cwd.children() if child.isSelected()]	# get selected nodes
	for sel in selected:
		childNode = hou.node(sel.path()+"/"+childNodeName)
		childNode.parm(param).set(value)
Exemple #8
0
def pressButton(childNodeName="cue_pt_lgt_to_h11", message="execute"):
	scene_viewer = toolutils.sceneViewer()
	cwd = scene_viewer.pwd()
	selected = [child for child in cwd.children() if child.isSelected()]	# get selected nodes
	for sel in selected:
		childNode = hou.node(sel.path()+"/"+childNodeName)
		childNode.parm(message).pressButton()
def setup():
    v = toolutils.sceneViewer()
    sel = hou.selectedNodes()
    if sel:
        paint = toolutils.findChildNodeOfTypeWithParms(sel[0],
                                                      'paint',
                                                      {'overridecd':1, 'cdname': 'density'})
        if paint:
            paint.setCurrent(True)
            v.enterCurrentNodeState()
            return

    scatter_geo = v.selectObjects("Please select objects to copy to",
                                  use_existing_selection=False,
                                  allowed_types=('geo',),
                                  allow_multisel=False)
    source_geo = v.selectObjects("Please select source",
                                  use_existing_selection=False,
                                  allowed_types=('geo',))

    if not (scatter_geo and source_geo):
        return
    elif len(scatter_geo) >1 or len(source_geo)>1:
        hou.ui.displayMessage("Please select one geometry object")
        return

    scatter_geo, = scatter_geo
    source_geo, = source_geo

    geo = hou.node('/obj').createNode('geo','copy', run_init_scripts=False)
    merge_source = geo.createNode('object_merge','merge_source')
    merge_source.parm('objpath1').set(source_geo.path())
    merge_source.parm('xformtype').set(1)

    merge_scatter = geo.createNode('object_merge','merge_scatter')
    merge_scatter.parm('objpath1').set(scatter_geo.path())
    merge_scatter.parm('xformtype').set(1)

    scatter_geo.setDisplayFlag(False)
    source_geo.setDisplayFlag(False)

    paint = soptoolutils.buildPaintNode(merge_scatter, None,
                                        parms={'overridecd':1, 'cdname': 'density'},
                                        props={'attribdef': 0, 'fgcolor': 0.4, 'opacity': 0.3, 'radius': 1 })

    scatter_sop = geo.createNode('scatter')
    scatter_sop.parm('usedensityattrib').set(1)
    scatter_sop.parm('forcetotal').set(0)
    scatter_sop.parm('emergencylimit').set(500)
    scatter_sop.setInput(0, paint)

    copy_sop = geo.createNode('copy')
    copy_sop.parm('pack').set(True)
    copy_sop.setInput(0, merge_source)
    copy_sop.setInput(1, scatter_sop)
    copy_sop.setDisplayFlag(True)

    geo.layoutChildren()
    paint.setCurrent(True)
    v.enterCurrentNodeState()
Exemple #10
0
    def takeScreenshot():
        '''Take a screenshot and save it in the temp folder'''
        import tempfile

        res = [1024, 768]

        filename = "%s.jpg" % (os.path.join(tempfile.gettempdir(),
                                            str(uuid.uuid4())))

        desktop = hou.ui.curDesktop()
        scene_view = toolutils.sceneViewer()

        if scene_view is None or (scene_view.type() !=
                                  hou.paneTabType.SceneViewer):
            raise hou.Error("No scene view available to flipbook")
        viewport = scene_view.curViewport()

        if viewport.camera() is not None:
            res = [
                viewport.camera().parm('resx').eval(),
                viewport.camera().parm('resy').eval()
            ]

        view = '%s.%s.world.%s' % (desktop.name(), scene_view.name(),
                                   viewport.name())

        executeCommand = "viewwrite -c -f 0 1 -r %s %s %s %s" % (
            res[0], res[1], view, filename)

        hou.hscript(executeCommand)
        return filename
Exemple #11
0
def sculptEnd(scriptargs):
    sopnode = scriptargs['node']
    viewer = toolutils.sceneViewer()
    node = sopnode.node("FLOWER")
    node.setCurrent(True, True)
    node.setRenderFlag(True)
    node.setDisplayFlag(True)
    viewer.enterCurrentNodeState()
Exemple #12
0
def pressButton(childNodeName="cue_pt_lgt_to_h11", message="execute"):
    scene_viewer = toolutils.sceneViewer()
    cwd = scene_viewer.pwd()
    selected = [child for child in cwd.children()
                if child.isSelected()]  # get selected nodes
    for sel in selected:
        childNode = hou.node(sel.path() + "/" + childNodeName)
        childNode.parm(message).pressButton()
Exemple #13
0
def setBypass(childNodeName="prep_shell_pt/setPtoBlendBlendP", flag=1):
    scene_viewer = toolutils.sceneViewer()
    cwd = scene_viewer.pwd()
    selected = [child for child in cwd.children()
                if child.isSelected()]  # get selected nodes
    for sel in selected:
        childNode = hou.node(sel.path() + "/" + childNodeName)
        childNode.bypass(flag)
Exemple #14
0
def viewname():
    viewer = toolutils.sceneViewer()
    viewname = {
        'desktop' : viewer.pane().desktop().name(),
        'pane' : viewer.name(),
        'type' :'world',
        'viewport': viewer.curViewport().name()
    }
    return '{desktop}.{pane}.{type}.{viewport}'.format(**viewname)
Exemple #15
0
def viewname():
    viewer = toolutils.sceneViewer()
    viewname = {
        'desktop': viewer.pane().desktop().name(),
        'pane': viewer.name(),
        'type': 'world',
        'viewport': viewer.curViewport().name()
    }
    return '{desktop}.{pane}.{type}.{viewport}'.format(**viewname)
Exemple #16
0
def layer_stack_composition():
    print("Launching Layer Stack Composition!")
    import importlib
    importlib.reload(_description)
    editor = _description.LayersComposition(parent=hou.qt.mainWindow())
    viewer = toolutils.sceneViewer()
    stage = viewer.stage()
    editor.setStage(stage)
    editor.show()
Exemple #17
0
def resetExpr(childNodeName="path_filament/pre_speckspline_TO_H11",
              param="fx",
              expr="FS"):
    scene_viewer = toolutils.sceneViewer()
    cwd = scene_viewer.pwd()
    selected = [child for child in cwd.children()
                if child.isSelected()]  # get selected nodes
    for sel in selected:
        childNode = hou.node(sel.path() + "/" + childNodeName)
        childNode.parm(param).setExpression(expr)
Exemple #18
0
def resetParm(childNodeName="path_filament/cue_wisp_pts/io_Cue1",
              param="save_first",
              value=0):
    scene_viewer = toolutils.sceneViewer()
    cwd = scene_viewer.pwd()
    selected = [child for child in cwd.children()
                if child.isSelected()]  # get selected nodes
    for sel in selected:
        childNode = hou.node(sel.path() + "/" + childNodeName)
        childNode.parm(param).set(value)
Exemple #19
0
 def viewwrite(self, options='', outpath='ip'):
     current_view = self.viewname(toolutils.sceneViewer())
     pane = current_view.split('.')[1]
     hou.hscript('pane -f 1 %s' % pane)
     go = hou.ui.displayMessage('Viewport ready?')
     if not go:
         hou.hscript('viewwrite {} {} {}'.format(options, current_view,
                                                 outpath))
         #print 'viewwrite {} {} {}'.format(options, current_view, outpath)
     hou.hscript('pane -f 0 %s' % pane)
Exemple #20
0
def makeControl():
    cwd = toolutils.sceneViewer().pwd()
    selected = [child for child in cwd.children() if child.isSelected()]
    if len(selected) == 0:
        raise hou.InvalidInput("need to select one Sop")
    node = selected[0]  # only work on first selected node

    # create node:
    nullNode = node.parent().createNode('null', node_name='CONTROL')
    nullNode.setColor(hou.Color((0, 0, 0)))
Exemple #21
0
def makeControl():
	cwd = toolutils.sceneViewer().pwd()
	selected = [child for child in cwd.children() if child.isSelected()]
	if len(selected) == 0:
		raise hou.InvalidInput("need to select one Sop")	
	node = selected[0]	# only work on first selected node
		
	# create node:
	nullNode = node.parent().createNode('null', node_name='CONTROL')
	nullNode.setColor(hou.Color((0,0,0)))
Exemple #22
0
def sculptStamenBase(scriptargs):
    sopnode = scriptargs['node']
    viewer = toolutils.sceneViewer()

    sculpt = sopnode.node("stamenbase_sculpt")

    sculpt.setCurrent(True, True)
    sculpt.setRenderFlag(True)
    sculpt.setDisplayFlag(True)
    viewer.enterCurrentNodeState()
Exemple #23
0
def flipBooker():
    viewer = tu.sceneViewer()
    settings = viewer.flipbookSettings().stash()

    path = hou.getenv("HIP") + "/prev/" + hou.getenv("VER") + "/"
    if not os.path.isdir(path):
        os.makedirs(path)
    path = path + "out_$F4.jpg"
    settings.output(path)

    viewer.flipbook(settings=settings)
Exemple #24
0
def cpSetOrigin(new_origin,construction_plane = []):
	if construction_plane == []:
		construction_plane = toolutils.sceneViewer().constructionPlane()
	# revert center offset
	t = hou.hmath.buildTranslate(hou.Vector3([-2,-2,0]))
	construction_plane.setTransform(t.inverted()*construction_plane.transform())
	# process
	translation = hou.hmath.buildTranslate(hou.Vector3(new_origin) - cpOrigin(construction_plane))
	construction_plane.setTransform(construction_plane.transform() * translation)
	# apply center offset
	construction_plane.setTransform(t*construction_plane.transform())
Exemple #25
0
def populateData(node=None, path=None):
    # print "\n"*20
    data = {
        "element": "temp",
        "version": 0,
        "version2": 0,
        "f1": 1000,
        "f2": 1000
    }

    scene = toolutils.sceneViewer()
    viewport = scene.curViewport()
    camera_name = 'persp'
    camera_res = [1920, 1080]
    frange = [1000, 1000]

    if viewport.camera():
        camera_name = viewport.camera().name()
        camera_res = viewport.camera().parmTuple('res').eval()

    if not path:
        path = os.path.dirname(hou.hipFile.path())

    def updateFromParm(node, data, parm_name):
        if node:
            parms = node.parms()
            if parm_name in [x.name() for x in parms]:
                data[parm_name] = node.evalParm(parm_name)

    check_list = ["element", "version", "version2", "f1", "f2"]
    [updateFromParm(node, data, x) for x in check_list]

    path_dir = "{root}/playblast/{element}/{version}".format(
        root=path,
        element=data['element'],
        version=str(data['version']).zfill(4))

    if not os.path.exists(path_dir):
        os.makedirs(path_dir)

    path_img = os.path.join(path_dir, camera_name + '.$F4.jpg')

    data["scene"] = scene
    data["viewport"] = viewport
    data["camera_name"] = camera_name
    data["camera_resx"] = camera_res[0]
    data["camera_resy"] = camera_res[1]
    data['path'] = path_img
    data['cropOutMaskOverlay'] = 1
    data['outputToMPlay'] = 0

    return data
Exemple #26
0
def viewport_selection(kwargs, groupparm="group", grouptypeparm="grouptype"):
    me = kwargs['node']
    # enable active viewport interactive grouping
    if hou.isUIAvailable():
        scene_viewer = toolutils.sceneViewer()
        selection = scene_viewer.currentGeometrySelection()
        if selection:
            me.parm('group').set(selection.mergedSelectionString())
            type = selection.geometryType()
            if type == hou.geometryType.Points:
                me.parm('grouptype').set(3)
            if type == hou.geometryType.Primitives:
                me.parm('grouptype').set(4)
Exemple #27
0
def cpSetNormal(normal_vector,construction_plane = []):
	if construction_plane == []:
		construction_plane = toolutils.sceneViewer().constructionPlane()
	# revert center offset
	t = hou.hmath.buildTranslate(hou.Vector3([-2,-2,0]))
	construction_plane.setTransform(t.inverted()*construction_plane.transform())
	# process
	existing_rotation = hou.Matrix4(construction_plane.transform().extractRotationMatrix3())
	rotation = existing_rotation * cpNormal(construction_plane).matrixToRotateTo(normal_vector)
	translation = hou.hmath.buildTranslate(cpOrigin(construction_plane))
	construction_plane.setTransform(rotation * translation) 
	# apply center offset
	construction_plane.setTransform(t*construction_plane.transform())
Exemple #28
0
def makeOut():
	cwd = toolutils.sceneViewer().pwd()
	selected = [child for child in cwd.children() if child.isSelected()]
	if len(selected) == 0:
		raise hou.InvalidInput("need to select one Sop")	
	node = selected[0]	# only work on first selected node
#	node_type = node.type()
#	if node_type.category().name() != 'Sop':
#		raise hou.InvalidInput("only works on Sops")
		
	# create node:
	nullNode = node.parent().createNode('null', node_name='OUT')
	nullNode.setInput(0, node)
	nullNode.setColor(hou.Color((0,0,0)))
Exemple #29
0
def makeOut():
    cwd = toolutils.sceneViewer().pwd()
    selected = [child for child in cwd.children() if child.isSelected()]
    if len(selected) == 0:
        raise hou.InvalidInput("need to select one Sop")
    node = selected[0]  # only work on first selected node
    #	node_type = node.type()
    #	if node_type.category().name() != 'Sop':
    #		raise hou.InvalidInput("only works on Sops")

    # create node:
    nullNode = node.parent().createNode('null', node_name='OUT')
    nullNode.setInput(0, node)
    nullNode.setColor(hou.Color((0, 0, 0)))
Exemple #30
0
def screenShot():
    """take a screen shot of the current viewport at the current frame"""
    help(screenShot)
    import hou
    import toolutils
    import os
    #selected node
    nodeSelect = hou.selectedNodes()
    path = hou.expandString("$HIP")
    frame = hou.expandString("$F")
    frame = int(frame)
    black = hou.Color((0, 0, 0))
    #name check there is a node selected
    if len(nodeSelect) < 1:
        print("!!!    error: select a node    !!!")
    else:
        for node in nodeSelect:
            name = node.name()
            node.setColor(black)
        #Get the current Desktop
        desktop = hou.ui.curDesktop()
        # Get the scene viewer
        scene = toolutils.sceneViewer()
        flipbook_options = scene.flipbookSettings().stash()
        # set frame range
        flipbook_options.frameRange((frame, frame))
        #set output path
        root = "{1}/{2}/{0}/".format(name, path, "screenShot")
        if os.path.exists(root):
            listPath = os.listdir(root)
            inc = len(listPath)
            inc = int(inc)
            outputPath = "{}{}.{:04d}.jpg".format(root, name, inc)
        else:
            os.makedirs(root)
            inc = 0
            outputPath = "{}{}.{:04d}.jpg".format(root, name, inc)
        #set flipbook current path
        flipbook_options.output(outputPath)
        #run flipbook
        scene.flipbook(scene.curViewport(), flipbook_options)
        # reload image
        print(outputPath)
        editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
        image = hou.NetworkImage()
        image.setPath(outputPath)
        image.setRect(hou.BoundingRect(0, 0, 5, 5))
        image.setRelativeToPath(node.path())
        editor.setBackgroundImages([image])
Exemple #31
0
def main():
    view = toolutils.sceneViewer()
    sel = view.selectObjects('请选择一个相机', allowed_types=('cam', ))
    if len(sel) > 0:
        if sel[0].type().name() == 'cam':
            resolution = hou.ui.readInput('set Resolution',
                                          buttons=('Set', 'close'),
                                          title='set Resolution',
                                          initial_contents='1920-1080',
                                          close_choice=1,
                                          default_choice=0)
            resx = resolution[1].split('-')[0]
            resy = resolution[1].split('-')[1]
            oldcam = sel[0]
            if resolution[0] == 0:
                setfit(oldcam, resx, resy)
Exemple #32
0
def techrig_userInput_startBoneEndBone():
    import toolutils 
    sViewer = toolutils.sceneViewer()
    startBone = sViewer.selectObjects('Select start bone, press enter to confirm', allowed_types=('bone',), allow_multisel=False)
    if (startBone == ()):
        hou.ui.displayMessage('Start bone not selected, terminating tool', severity=hou.severityType.Error)
        return (None, None)
    startBone[0].setSelected(0, True)
    endBone = sViewer.selectObjects('Select end bone, press enter to confirm', allowed_types=('bone',), allow_multisel=False)
    if (endBone == ()):
        hou.ui.displayMessage('End bone not selected, terminating tool', severity=hou.severityType.Error)
        return (None, None)
    if (not techrig_findChildInHierarchy(startBone[0], endBone[0])):
        hou.ui.displayMessage('End bone does not exist in same hierarchy as start bone, terminating tool', severity=hou.severityType.Error)
        return (None, None)
    return (startBone[0],
     endBone[0])
Exemple #33
0
def createThumbnailBase(selected_obj, res=150, view_grid=False):
    """Create a thumbnail image from current scene viewer and selected object(s)
        return the binary data of the jpg file
    """
        
    viewer = toolutils.sceneViewer()
    viewport = viewer.curViewport()
    if not viewer:
        hou.ui.displayMessage("No scene viewer found.",
                                severity=hou.severityType.Error)
        return None
    
    cur_state = viewer.currentState()
    viewer.enterViewState()
        
    construct_plane = viewer.constructionPlane()
    construct_state = construct_plane.isVisible()
    construct_plane.setIsVisible(view_grid)
    
    _desktop =  hou.ui.curDesktop()
    desktop = _desktop.name()
    _panetab =  _desktop.paneTabOfType(hou.paneTabType.SceneViewer)
    panetab = _panetab.name()
    persp = _panetab.curViewport().name()
    camera_path = nodeInfos.get_viewer_fullpath()
    
    selected_obj.setCurrent(False)
    
    output = tempfile.gettempdir() + "\\" + selected_obj.name() + ".jpg"
    cmd = 'viewwrite -f $F $F -c -q 4 -r ' + \
          str(res) + ' ' + str(res) + ' ' + \
          camera_path + ' "' + output + '"'
    out, err = hou.hscript(cmd)
    
    if err:
        print err
    
    # clean temporary camera and set options back to initial values
    viewer.setCurrentState(cur_state)
    construct_plane.setIsVisible(construct_state)
    
    selected_obj.setCurrent(True)

    with open(output, 'rb') as f:
        return f.read()
Exemple #34
0
def createCurve(kwargs):
    # select the current SOP node from the args
    parentNode = kwargs['node'].parent()
    node = kwargs['node']
    # Select the current viewer to toogle the controsl
    viewer = toolutils.sceneViewer()

    # LINK: http://sidefx.jp/doc/hom/assetscripts.html
    # hou.ui.displayMessage("You created " + kwargs['script_multiparm_index'])

    # Check for midify curve if exist
    curve_node_name = 'curve_create' + kwargs['script_multiparm_index']
    curve_node = parentNode.node(curve_node_name)
    if (curve_node is None):
        # Create a curve node if not exist
        curve_node = parentNode.createNode('curve', curve_node_name)
        # Create a curve node if not exist
        group_node = parentNode.createNode('group', "group_" + curve_node_name)
        group_node.setNextInput(curve_node)

        # Add this group into the custom group tag
        node.setParms({
            "group" + kwargs['script_multiparm_index']:
            "group_" + curve_node_name,
            "name" + kwargs['script_multiparm_index']:
            "curve_created_" + kwargs['script_multiparm_index']
        })

        # Select the merge curves nodes to connect the node created
        merge_curves = parentNode.node("merge_curves")
        if (merge_curves is None):
            # If merge node doesn't exist create a new one
            merge_curves = parentNode.createNode("merge", "merge_curves")
            # Get the input connected to the first input and set to this one
            if (len(node.inputs())):
                merge_curves.setNextInput(node.inputs()[0])
            # Connect the merge node into the current Sop
            node.setInput(0, merge_curves)

        # Append this new curve into the merge node
        merge_curves.setNextInput(group_node)

    # Enter into curve to edit
    curve_node.setCurrent(True, True)
    viewer.enterCurrentNodeState()
Exemple #35
0
def run():
    sc = toolutils.sceneViewer()

    # Get Current View
    view = sc.curViewport()

    # Settings
    s = sc.flipbookSettings()
    s.stash()

    # Set FrameRange
    range = (hou.playbar.playbackRange())
    s.frameRange(range)

    # Set Resolution
    cam = view.camera()
    if cam is not None:
        res = (cam.evalParm('resx'), cam.evalParm('resy'))
        s.resolution(res)
        s.cropOutMaskOverlay(True)

        disk = hou.ui.displayMessage("Render to Disk?", buttons=('No', 'Yes'))

        if disk == 1:
            # Set Output Name and Path
            node = cam.parent().parent()
            if node.type().name() != "qLib::shot_ql::1":
                path = cam.name()
            else:
                path = cam.parent().parent().name()

            dir = hou.getenv('HIP') + '/' + 'flipbook/' + path

            if not os.path.isdir(dir):
                os.makedirs(dir)
            path = '$HIP/flipbook/' + path + '/' + path + '_$F4.jpg'

            s.output(path)
            sc.flipbook(viewport=view, settings=s, open_dialog=False)
        else:
            s.output("")
            sc.flipbook(viewport=view, settings=s, open_dialog=False)

    else:
        hou.ui.displayMessage('Please create a Camera')
Exemple #36
0
def main():
    view = toolutils.sceneViewer()
    selnodes = view.selectObjects('请选择一个cam或包含cam的AlembicArchive', allowed_types=['cam'])
    if len(selnodes) > 0:
        resolution = hou.ui.readInput('set Resolution', buttons=('Set', 'close'), title='set Resolution',
                                      initial_contents='1920-1080', close_choice=1, default_choice=0)
        resx = resolution[1].split('-')[0]
        resy = resolution[1].split('-')[1]
        for selnode in selnodes:
            print selnode.name()
            camlist = getcamlist(selnode)
            move_iter = 0
            for cam in camlist:
                print cam.name()
                camset = CamFit(selnode, cam)
                if resolution[0] == 0:
                    camset.setfit(resx, resy, move_iter)
                    move_iter += 2
            del camlist[:]
Exemple #37
0
 def _updatePrim():
     # find a cheaper way for this?
     viewer = toolutils.sceneViewer()
     stage = viewer.stage()
     if not stage:
         editor.clear()
         editor._prim = None
         return
     selection = viewer.currentSceneGraphSelection()
     prims = tuple(stage.GetPrimAtPath(path) for path in selection)
     prim = next(iter(prims), None)
     if not prim:
         if editor._prim:
             editor.clear()
             editor._prim = None
     else:
         if prim != editor._prim:
             editor.setPrim(prim)
             editor._prim = prim
Exemple #38
0
    def upload(self):
        btpVfxProject.SetProjName(self.ui.label_Project.text())
        versionStr = btpVfxProject.TimeMark()
        taskNode = hou.node("/obj/%s" % self.rootNode)
        taskNode.setParms({"version": versionStr})
        globalTaskPath = btpVfxProject.AttachRootPath(
            self.ui.label_Project.text(), self.ui.label_task.text())
        hipFile = "%s/%s" % (globalTaskPath, self.ui.label_taskFile.text())
        hou.hipFile.save(hipFile)
        self.ui.progressBar_taskFiles.setValue(10)

        projInfo = btpVfxProject.ProjInfo()
        globalTaskPreviewName = "%s/%s_preview" % (globalTaskPath,
                                                   self.rootNode)
        previewFile = "%s.$F4.jpg" % globalTaskPreviewName
        scene = toolutils.sceneViewer()
        flipbook_options = scene.flipbookSettings().stash()

        frameRange = (self.ui.spinBox_startFrame.value(),
                      self.ui.spinBox_endFrame.value())
        flipbook_options.useResolution(True)
        flipbook_options.resolution((projInfo["resW"], projInfo["resH"]))
        flipbook_options.frameRange(frameRange)
        flipbook_options.output(previewFile)
        viewport = scene.curViewport()
        viewport.setCamera(hou.node("/obj/%s_Cam" % self.rootNode))
        scene.flipbook(viewport, flipbook_options)
        previewFile_jpgSeq = "%s.####.jpg" % globalTaskPreviewName
        previewFile_mov = "%s.mov" % globalTaskPreviewName
        btpVfxProject.JpgToMov(previewFile_jpgSeq, previewFile_mov, frameRange,
                               "Nobody", self.ui.label_task.text(), versionStr)
        btpVfxProject.DeleteFiles("%s.????.jpg" % globalTaskPreviewName)
        self.ui.progressBar_taskFiles.setValue(20)

        btpVfxProject.SaveVersion(
            projName=self.ui.label_Project.text(),
            taskPath=self.ui.label_task.text(),
            files=[hipFile, self.imagePathName, previewFile_mov],
            comment=self.ui.textEdit_comment.toHtml(),
            timeMark=versionStr,
            progressBar=self.ui.progressBar_taskFiles)
        self.accept()
Exemple #39
0
def extractChildren():
	scene_viewer = toolutils.sceneViewer()
	cwd = scene_viewer.pwd()
	selected = [child for child in cwd.children() if child.isSelected()]
	extractNode = hou.node(cwd.path()).createNode("geo", "extract_node", run_init_scripts=False )	# create empty geo node
	merge_sop = extractNode.createNode("object_merge")
	
	num_objs = len(selected)
	merge_paths_dict = {}
	i = 1
	for sel in selected:
		merge_paths_dict["objpath"+str(i)] = sel.path() + "/OUT"
		i = i + 1		
	
	parm_dict = {"numobj":num_objs, "xformtype":1}
	merge_sop.setParms(parm_dict)
	merge_sop.setParms(merge_paths_dict)
		
	scene_viewer.setPwd(merge_sop.parent())
	toolutils.homeToSelectionNetworkEditorsFor(merge_sop)	
	extractNode.setColor(hou.Color((0,0,0)))
	extractNode.moveToGoodPosition()
Exemple #40
0
import sys
import os

TOOLS_PATH = hou.getenv('CUSTOM_PYTHON_TOOLS')
sys.path.append(TOOLS_PATH)
from gui2one_utils import gui2one_utils
reload(gui2one_utils)

#print kwargs

activepane = toolutils.activePane(kwargs)
if activepane.type() != hou.paneTabType.SceneViewer:
    raise hou.Error("This tool cannot run in the current pane")

scene_viewer = toolutils.sceneViewer()
nodetypename = "delete"

# Obtain a geometry selection
geo_types = (hou.geometryType.Primitives, )
selection = scene_viewer.selectGeometry(
    "Select the primitives from which to create debris and press Enter to complete",
    geometry_types=geo_types,
    allow_obj_sel=True)
# The following will raise an exception if nothing was selected.
if len(selection.nodes()) == 0:
    raise hou.Error("Nothing was selected.")

#
# Create Source
#