Skip to content

Instantly share code, notes, and snippets.

View loonghao's full-sized avatar
😀

Hal loonghao

😀
  • Shenzhen
View GitHub Profile
@loonghao
loonghao / swap_node.py
Created August 14, 2020 10:20
swap selection nodes
import nuke
import nukescripts
def get_connected_nodes(node):
input_nodes = [(i, node.input(i)) for i in range(node.inputs())]
output_nodes = []
for depNode in nuke.dependentNodes(nuke.INPUTS | nuke.HIDDEN_INPUTS, node):
for i in range(depNode.inputs()):
if depNode.input(i) == node:
@loonghao
loonghao / clarisse_parser.py
Created August 14, 2020 03:21
Provides function to parse dependencies files from clarisse working file.
"""Provides function to Parse dependencies files from working file."""
# Import built-in modules
from functools import partial
import re
class Parser(object):
"""Parser for parsing dependencies files from work file.
import time
import watchdog.events
import watchdog.observers
class Handler(watchdog.events.RegexMatchingEventHandler):
def __init__(self):
# Set the patterns for PatternMatchingEventHandler
super(Handler, self).__init__(regexes=[r"*.json"])
import pymel.core as pm
def getBuildOrder(face):
"""Returns the uvs of a face in the build order """
verts = []
vtxFaces = pm.ls(pm.polyListComponentConversion(face, toVertexFace=True), flatten=True)
for vtxFace in vtxFaces:
uvs = pm.polyListComponentConversion(vtxFace, fromVertexFace=True, toUV=True)
verts.append(uvs[0])
return verts
@loonghao
loonghao / export_point_attribute.py
Last active March 4, 2020 11:45
Export houdini point attribute
import hou
import json
from pprint import pprint
node = hou.selectedNodes()[0]
for frame in range(810, 1510):
geo = node.geometryAtFrame(frame)
filename = r"c:\cgfx_rnd\point_data\{}.{}.json".format(node.name(), frame)
print filename
with open(filename, "w") as json_object:
# -*- coding: utf-8 -*-
"""
module author: Long Hao <[email protected]>
"""
from pprint import pprint
class ChRecord(object):
def __init__(self, namespace, file_path, sel_sets=None):