Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Marcus Ottosson
    @mottosso
    It's easy, we'll make assets that have something wrong with them; like the wrong file extension.
    We publish it, and it passes.
    Then we make the plug-in to catch the error, so that it cannot be published.
    Job done.
    David Martinez
    @davidmartinezanim
    sure
    let me prepare all those scenes once I get home
    Marcus Ottosson
    @mottosso
    Let's not overwhelm ourselves though, let's start with one
    David Martinez
    @davidmartinezanim
    should I name them something like: test_validatorName_failure_ARas we did before?
    Marcus Ottosson
    @mottosso
    Yeah, sounds good.
    David Martinez
    @davidmartinezanim
    ok
    I will be leaving in 10 minutes. Once I go home, I will prepare the scene and we can take it from there, yeah?
    Marcus Ottosson
    @mottosso
    Sure, lets do that!
    Marcus Ottosson
    @mottosso

    Let me just elaborate on my reasoning for suggesting we do it this way.

    At the moment, we've got a number of plug-ins that we are more or less polishing/making perfect. The problem is that we can't know what perfect is until they actually get used. Ideally, that would be by your audience; the artists.

    If we can't have that, then the next best thing is to put ourselves in the guinea pig cage.

    The best way to do that is by first clarifying the problem (i.e. building the broken asset) and getting feedback on when we've actually solved it (i.e. implementing the validator that finds the error).

    In a nutshell; this is what test-driven development is all about. In programming terms, you could write a full software this way before ever hitting a line of code. For example.

    $ dir
     Volume in drive C has no label.
     Volume Serial Number is 8287-EFA2
    
     Directory of C:\
    
    06/03/2015  14:33    <DIR>          Program Files
    05/07/2014  12:07    <DIR>          Windows

    Bam, we've just written dir. From here, all we have to do is to write the code that outputs this exact thing and when it does, we're done. :)

    In plug-in terms, it's exactly like I mentioned. We construct an asset, as realistically as possible, containing an error that we're looking to catch; like the .mb suffix. We can then both see what we've got to start with, and we can easily illustrate where we're going. Once the plug-in has been written, and .mb files are not publishable anymore, we can move on, knowing that it works as opposed to hoping that it will.

    David Martinez
    @davidmartinezanim
    It makes a lot of sense, yeah

    Let's see if this is a better way of working.

    Description

    We want to make sure that the maya scene being validated does not contain any audio files.

    Test Scene

    I've added the following scenes:

    • test_validateMAFormat_failure_AR.mb
    • test_validateNoAudio_AR.ma

    Desired output when it fails

    image

    Marcus Ottosson
    @mottosso
    Hey David, I'll be out for dinner for a while but will be back.
    David Martinez
    @davidmartinezanim
    sure thing mate
    have a nice meal
    Marcus Ottosson
    @mottosso
    But that looks prefect so far, exactly what I meant.
    Assuming that the plug-in was written after you made the scene.
    That's what I'd like us to try out, to make the scenes first, and to have them allow bad data to be extracted.
    Then we catch it
    David Martinez
    @davidmartinezanim
    yeah, we will take that approach
    Marcus Ottosson
    @mottosso
    Awesome sauce
    See you in a bit
    David Martinez
    @davidmartinezanim
    see you
    David Martinez
    @davidmartinezanim
    Although audio nodes will not be part of a regular export (as they are not connected to any of the DAG nodes in any way), I still want to check for them. The reasoning behind that is the same as for the ma files. For certain kinds of assets, it is looked upon to commit to the subversion system, files that contain audio files and that is the reason to have the plugin.
    David Martinez
    @davidmartinezanim

    Selector

    from pyblish_maya.lib import maintained_selection
    import pyblish_tdm.utilities as utilities
    import pyblish.api
    from maya import cmds
    
    
    class SelectSuperMinifigGameInstances(pyblish.api.Selector):
        hosts = ["maya"]
    
        def process_context(self, context):
            """Produce instances of family Super_Minifig_Game_AR.AR"""
    
            current_file = cmds.file(sceneName=True, query=True)
            family = utilities.family_from_path(current_file)
    
            if not family == 'Super_Minifig_Game_AR.AR':
                return
    
            asset_name = utilities.name_from_path(current_file)
            instance = context.create_instance(name=asset_name)
            instance.set_data("family", family)
    
            with maintained_selection():
                cmds.select(cmds.ls(type=["dagNode", "objectSet", "audio"]),
                            noExpand=True)
    
                for node in cmds.file(exportSelected=True,
                                      preview=True,
                                      constructionHistory=True,
                                      force=True):
    
                    child = utilities.MayaNode(node)
                    child.type = cmds.nodeType(node)
    
                    # Determine if current node is a user set
                    userSet = False
                    if child.type == 'objectSet':
                        userSet = True
                        for attr in ['verticesOnlySet', 'renderableOnlySet']:
                            if cmds.objExists(node + "." + attr):
                                if cmds.getAttr(node + "." + attr):
                                    userSet = False
                                    break
    
                    child.data['userSet'] = userSet
                    instance.add(child)
    
            instance.set_data("Selector", type(self).__name__)

    Validator

    import pyblish.api as pyblish
    
    
    @pyblish.log
    class ValidateNoAudio(pyblish.Validator):
        """Ensure that there are no audio nodes in the scene"""
    
        hosts = ['maya']
        families = ['Super_Minifig_Game_AR.AR']
    
        def process_instance(self, instance):
            audio_nodes = list()
    
            for node in instance:
                    if node.type == 'audio':
                        audio_nodes.append(node)
    
            if audio_nodes:
                raise pyblish.ValidationError("Audio nodes found in the"
                                              "scene: %s\n" % audio_nodes)
    David Martinez
    @davidmartinezanim
    I will prepare all the scenes tonight so we can try them tomorrow and work our way to finishing the plugins. I won't code any more tonight though as I need to study.
    Marcus Ottosson
    @mottosso
    Sorry for being so late, but it looks good from here.
    Let's try things out tomorrow morning if you're around.
    David Martinez
    @davidmartinezanim
    np
    Marcus Ottosson
    @mottosso
    I'd like us to try and mimick as much as possible of your work pipeline in the mock project.
    Including extracting, and committing to an SVN
    The whole series of steps.
    I think only then will it become obvious what works and what doesn't
    Think we could achieve that?
    David Martinez
    @davidmartinezanim
    thought committing would be manual but we can try and do that as conform. We might bt you might have to install svn on your virtualenv
    Marcus Ottosson
    @mottosso
    We don't need to go that far, empty commands that look like they're doing what they're supposed to be doing is well enough.
    For example, how does committing look at the moment?
    David Martinez
    @davidmartinezanim
    well, we do that using window#s explorer. although there are commands that you could use in the command line to do the same
    Marcus Ottosson
    @mottosso
    Ah, that's good, we'll work up something that looks like the command line interface
    $ cd project\publised_asset
    $ svn commit --all
    Or however it might look like :)
    I've got to scoot again, but we'll pick it up tomorrow!
    David Martinez
    @davidmartinezanim
    sure
    David Martinez
    @davidmartinezanim
    @mottosso do you think we could do it here? I just want to talk without having to do some information hiding. just for the sake of speed
    It will be easier to explain things
    and paste unmodified code
    Marcus Ottosson
    @mottosso
    Sure, let's do that, but this room isn't private.