Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user defined time frame or frames #20

Closed
aardschok opened this issue May 3, 2017 · 2 comments
Closed

Add user defined time frame or frames #20

aardschok opened this issue May 3, 2017 · 2 comments

Comments

@aardschok
Copy link
Contributor

aardschok commented May 3, 2017

The user should be able to playblast a combination of small frames and frame ranges:

Example : 1-20, 25; 50; 75, 100-150
from-to, increment;

This translates to:

  1. Frames 1 to 20:
  2. Frames 25, 50 and 75
  3. Frames 100 to 150
@BigRoy
Copy link
Member

BigRoy commented May 3, 2017

To elaborate a bit on this, this would be similar to printing specific pages in applications like Word as seen here:

print_pages

Here's a quick function I wrote that parses it similar to how Word does it (and how V-Ray specific frame render settings supports it). Note that this supports both comma , and semicolon ; as separators.

import logging
import re

log = logging.getLogger(__name__)


def parse_frames(string):
    """Parse the resulting frames list from a frame list string.
    
    Examples
        >>> parse_frames("0-3;30")
        [0, 1, 2, 3, 30]
        >>> parse_frames("0,2,4,-10")
        [0, 2, 4, -10]
        >>> parse_frames("-10--5,-2")
        [-10, -9, -8, -7, -6, -5, -2]
    
    Args:
        string (str): The string to parse for frames.
        
    Returns:
        list: A list of frames
    
    """

    result = list()

    for raw in re.split(";|,", string):
        
        # Skip empty elements
        value = raw.strip().replace(" ", "")
        if not value:
            if raw:
                log.warning("Empty frame entry: '{0}'".format(raw))
            continue
            
        # Check for sequences (1-20) including negatives (-10--8)
        sequence = re.search("(-?[0-9]+)-(-?[0-9]+)", value)
        
        # Sequence
        if sequence:
            start, end = sequence.groups()
            frames = range(int(start), int(end) + 1)
            result.extend(frames)
            
        # Single frame
        else:
            try:
                frame = int(value)
            except ValueError:
                log.warning("Invalid frame description: '{0}'".format(value))
                continue
            result.append(frame)
            
    return result

@BigRoy
Copy link
Member

BigRoy commented May 3, 2017

Implemented with #25

@BigRoy BigRoy closed this as completed May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants