예제 #1
0
 def run(self, edit):
     connection, hou = hrpyc.import_remote_module(server=settings['host'], port=settings['port'])
     for region in self.view.sel():
         try:
             exec self.view.substr(region)
         except:
             traceback.print_exc(0)
예제 #2
0
def get_hou():
    global cached_hou

    if cached_hou is not None:
        return cached_hou[1]

    logging.debug("Getting hou ref")

    if 'hou' in sys.modules:
        cached_hou = (None, sys.modules['hou'])
        logging.debug("Got hou from env")
        return cached_hou[1]

    if os.name == 'nt':
        hfs = "C:/Program Files/Side Effects Software/Houdini 17.5.360"
        sys.path.append(joinw(hfs, "python27/lib/site-packages"))
        sys.path.append(joinw(hfs, "python27/libs"))
        sys.path.append(joinw(hfs, "python27/lib"))
        sys.path.append(joinw(hfs, "houdini", "python2.7libs"))
    else:
        hfs = '/Applications/Houdini/Current/Frameworks/Houdini.framework/Versions/Current/Resources'
        hou_path = join(hfs, "houdini", "python%d.%dlibs" % (sys.version_info[:2]))

        if hou_path not in sys.path:
            sys.path.append(hou_path)
        sys.path.append(join(hfs, 'Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'))

    import hrpyc
    cached_hou = hrpyc.import_remote_module()
    logging.debug("Got hou from remote module")
    return cached_hou[1]
예제 #3
0
 def run(self, edit):
     connection, hou = hrpyc.import_remote_module(server=settings['host'],
                                                  port=settings['port'])
     for region in self.view.sel():
         try:
             exec self.view.substr(region)
         except:
             traceback.print_exc(0)
예제 #4
0
    def exportModelToHoudini(self, filename, type, path):
        try:

            import hrpyc
            connection, hou = hrpyc.import_remote_module()
            name = filename.split(".")[0]
            if (type == "obj" or type == "fbx"):
                print("exportModelHoudiniOBJ")

                geo = hou.node('/obj').createNode('geo', name)
                fileNode = geo.createNode('file', name)
                fileNode.parm('file').set(path)

                prinShaderNode = hou.node('/mat').createNode(
                    'principledshader', name)
                prinShaderNode.parm('basecolor_useTexture').set(1)

                materialNode = geo.createNode('material', name + "_material")
                materialNode.parm('shop_materialpath1').set("/mat/" + name)
                materialNode.setInput(0, fileNode)
                materialNode.moveToGoodPosition()
                materialNode.setDisplayFlag(1)

            if (type == "jpg" or type == "jpeg"):
                try:
                    print("exportModelHoudiniJPG")
                    # 路径不能有中文
                    imgNode = hou.node('/img').createNode('img', "comp1")
                    imgNode = hou.node('/img/comp1').createNode('file', name)
                    # fileNode = imgNode.createNode('file', name)
                    imgNode.parm('filename1').set(path)
                except:
                    print("ExportPictureFail")

            #保存导出记录到资产数据库
            RTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                  time.localtime(time.time()))
            assetdb = client[type]
            assetcol = assetdb[filename]
            adict = {
                "UserName": self.username,
                "Time": RTime,
                "Operation": "Export"
            }
            assetcol.insert_one(adict)
            # 保存导出记录到用户数据库
            usercol = userdb[self.username]
            adict = {
                "FileName": filename,
                "Time": RTime,
                "Operation": "Export"
            }
            usercol.insert_one(adict)
        except:
            self.slot_show_message(MMessage.info,
                                   (u'导出失败!请确认Houdini是否配置成功或启动。'))
            print(path)
            print(type)
예제 #5
0
def connectToHou():
    '''{'del_path':'Houdini/connectToHou( )',
'icon':'$ICONDIR/houdini.png',
'usage':'$fun( )',
}
'''
    try:
        import hrpyc
        global connection, hou
        connection, hou = hrpyc.import_remote_module()
        print '--Connected to Houdini--'
    except:
        print '--Houdini no have opened--'
예제 #6
0
import os
# Houdini 上のpythonならhouはデフォルトインポートされているみたいなのでインポート処理を飛ばす
# 環境変数取れたら Houdini 上と判断
if not 'HFS' in os.environ:
    try:
        import hrpyc
        connection, hou = hrpyc.import_remote_module()
        toolutils = connection.modules["toolutils"]
    except:
        # 最後に定義されているhouのautocompleteが効くみたいなので例外側でインポート
        import hou
        import toolutils

obj = hou.node('/obj')
geo = hou.node('/obj/box_object')
copytopoints = geo.node('copytopoints1')
pointsfromvolume = geo.node('pointsfromvolume1')

# 01
color = geo.createNode('color')
color.parmTuple('color').set((1.0, 0.0, 0.0))
color.setInput(0, pointsfromvolume)
copytopoints.setInput(1, color)
copytopoints.parm('resettargetattribs').pressButton()

# 02
matnet = obj.createNode('matnet')
principledshader = matnet.createNode('principledshader', 'brick_material')
# 03
material = geo.createNode('material')
material_to_principledshader = material.relativePathTo(principledshader)
예제 #7
0
def run(port=8701):
    connect, hou = hrpyc.import_remote_module(port=port)
    return connect, hou