Exemple #1
0
def get_nodes(abc_file_path=""):

    """
    return all of the polymesh nodes from an alembic file.
    :param string abc_file_path: path to file
    :return:
    """

    # Handle the job environment variable
    if abc_file_path.find("$JOB") != -1:
        job_path = os.environ["JOB"]
        abc_file_path = abc_file_path.replace("$JOB", job_path)

    _abc, _abc_type, alembic_hierarchy = hou_abc.alembicGetSceneHierarchy(abc_file_path, "/")

    alembic_hierarchy_shapes = list()
    alembic_hierarchy_transforms = list()

    queue_alembic_hierarchy = list(alembic_hierarchy[::])

    # Loop through top level objects
    for xfrm, xfrm_type, children in queue_alembic_hierarchy:

        if xfrm_type == "cxform":
            alembic_hierarchy_transforms.append(xfrm)
        elif xfrm_type == "polymesh":
            alembic_hierarchy_shapes.append(xfrm)

        if children != tuple():
            queue_alembic_hierarchy.extend(children)

    return alembic_hierarchy_transforms, alembic_hierarchy_shapes
    def camera_menu(self, node):
        abc_file = node.evalParm('abcFile')
        cached_abc_file = node.cachedUserData('abc_file')

        if os.path.exists(abc_file):
            if not cached_abc_file or abc_file != cached_abc_file:
                sceneHier = abc.alembicGetSceneHierarchy(abc_file, '/')
                if sceneHier and sceneHier[2]:
                    self._camera_paths = []
                    self._find_camera('/', sceneHier[2])

                #Select first element to select something
                node.parm('cameraPath').set(0)

                menucamera_paths = [
                    x for pair in zip(self._camera_paths, self._camera_paths)
                    for x in pair
                ]

                node.setCachedUserData('abc_file', abc_file)
                node.setCachedUserData('menucamera_paths', menucamera_paths)

                return menucamera_paths
        else:
            return []

        return node.cachedUserData('menucamera_paths')
Exemple #3
0
        def _set_abc_from_maya(prim, attr, path):
            hierarchy = abc.alembicGetSceneHierarchy(abc_file, path)
            obj_name, obj_type, items = hierarchy

            if obj_type == "polymesh":
                # abc exported from Maya, the attribute is imprinted on
                # transform node.
                transform_path = "/".join(path.split("/")[:-1])
                return_code = set_attr(prim, attr, transform_path)
                return return_code
            return None
Exemple #4
0
def getAbcAttr(attrName):
    """
    Gets an alembic attribute from the cache
    Requires an 'abcFileName' detail attribute
    
    @attrName: name of attribute to retrieve
    @useTransform: looks on the parent node instead. Equivalent to using maya's transform instead of shape
    """

    geo = hou.pwd().geometry()
    time = hou.frame() / hou.fps()

    if geo.findGlobalAttrib("abcFileName") is not None:
        url = geo.attribValue("abcFileName")

        for childGeo in abc.alembicGetSceneHierarchy(url, "/")[2]:
            path = "/" + childGeo[0] + "/" + childGeo[2][0][0]

            x = abc.alembicArbGeometry(url, path, attrName, time)
            if (x[1] == True):
                alert(x)
    def get_alembic_hierarchy_tuple(self, alembic_path, object_path = '/'):
        """
        Return tuple of type (object_name, object_type, children).
        Each tuple represents an object exported with -root in the Alembic
        job args.
        """

        #path exists
        if not (os.path.isfile(alembic_path)):
            #log
            self.logger.debug('Alembic path does not exist. Returning empty tuple')
            return ()

        try:
            #alembic_hierarchy_tuple
            alembic_hierarchy_tuple = abc.alembicGetSceneHierarchy(alembic_path, object_path)

        except:
            #return empty tuple
            return ()

        return alembic_hierarchy_tuple
Exemple #6
0
    def get_alembic_hierarchy_tuple(self, alembic_path, object_path = '/'):
        """
        Return tuple of type (object_name, object_type, children).
        Each tuple represents an object exported with -root in the Alembic
        job args.
        """

        #path exists
        if not (os.path.isfile(alembic_path)):
            #log
            self.logger.debug('Alembic path does not exist. Returning empty tuple')
            return ()

        try:
            #alembic_hierarchy_tuple
            alembic_hierarchy_tuple = abc.alembicGetSceneHierarchy(alembic_path, object_path)

        except:
            #return empty tuple
            return ()

        return alembic_hierarchy_tuple
Exemple #7
0
#~ ~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

import _alembic_hom_extensions as abc

node = hou.pwd()
geo = node.geometry()


def alert(msg):
    hou.ui.displayMessage(str(msg))


#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

for geo in abc.alembicGetSceneHierarchy(url, "/")[2]:

    alert(abc.alembicUserProperty(url, geo[0], "Cd", 0))
'''
oldAttr = abc.alembicUserProperty("Cd")
alert(str(oldAttr))

r = float(oldAttr[5])
g = float(oldAttr[1])
b = float(oldAttr[2])
color = (r, g, b)
Cd = geo.addAttrib(hou.attribType.Point, "Cd", color)

for point in geo.points():
    point.setAttribValue(Cd, color)
Exemple #8
0
abcFile = abcLists[-1]
abcFullFile = abcPath + '/' + abcFile

# Set FrameRange
timeRange = abc.alembicTimeRange(abcFullFile)
if timeRange is not None:
    hou.playbar.setFrameRange(hou.playbar.frameRange()[0],
                              hou.timeToFrame(timeRange[1]) - 1)
    #hou.playbar.setPlaybackRange(hou.playbar.playbackRange()[0], hou.timeToFrame(timeRange[1])-1)

# Filter Camera, (Need Optimization!!!)
abcMenuTuples = abc.alembicGetObjectPathListForMenu(
    hou.expandString(abcFullFile))
cameraList = []
for i in set(abcMenuTuples):
    cameraABCObject = abc.alembicGetSceneHierarchy(abcFullFile, i)
    if cameraABCObject[1] == 'camera':
        cameraList.append(i)
cameraExclude = [
    '/front/frontShape', '/top/topShape', '/side/sideShape',
    '/persp/perspShape'
]
cameraList = [i for i in cameraList if i not in cameraExclude]
cameraList = [i for i in cameraList if ':' not in i]
if len(cameraList) == 1:
    cameraName = cameraList[0]
else:
    userSelect = hou.ui.selectFromTree(cameraList,
                                       exclusive=1,
                                       title='Select Camera')
    try: