Here is my code:

# Name:        Mocha Rotoscoping Via Blender
# Purpose:     Make rotoscoping more efficient
# Author:      Jeff Owens
# Created:     11/07/2011
# Copyright:   (c) jeff.owens 2011
# Licence:     Grasshorse
#!/usr/bin/env python
import sys
import os
import parser
import GetDir
filename = 'diving_board.shape4ae'
infile = 'Z:/Blender_Roto/'
#import bpy
#from mathutils import Vector

#below are taken from mocha export
x_width =2048
y_height = 778
z_depth = 0
frame = 20

import re

data_directory = 'Z:/Blender_Roto/' # windows
data_file = 'diving_board.shape4ae'
fullpath = data_directory + data_file


file = open(fullpath)
for line in file:
    current_line = line

    # massive room for optimized code here.

    # this assumes the last element of the line containing the words
    # "Units Per Second" is the number we are looking for.
    # this is a non float number, generally.
    if current_line.find("Units Per Second") != -1:
        fps = line_split = float(current_line.split()[-1])
        print("Frames Per Second:", fps)

    # source dimensions
    if current_line.find("Source Width") != -1:
        source_width = line_split = int(current_line.split()[-1])
        print("Source Width:", source_width)

    if current_line.find("Source Height") != -1:
        source_height = line_split = int(current_line.split()[-1])
        print("Source Height:", source_height)

    # aspect ratios
    if current_line.find("Source Pixel Aspect Ratio") != -1:
        source_px_aspect = line_split = int(current_line.split()[-1])
        print("Source Pixel Aspect Ratio:", source_px_aspect)

    if current_line.find("Comp Pixel Aspect Ratio") != -1:
        comp_aspect = line_split = int(current_line.split()[-1])
        print("Comp Pixel Aspect Ratio:", comp_aspect)

    # assumption, ae file can contain multiple mocha shapes.
    # without knowing the exact format i will limit the script
    # to deal with one mocha shape being animated N frames.

    # this gathers the shape details, and frame number but does not
    # include error checking yet.
    if current_line.find("XSpline") != -1:

        # record the frame number.

        frame ="\s*(\d*)\s*XSpline", current_line)
        if != None:
            frame =
            print("frame:", frame)

        # pick part the part of the line that deals with geometry
        match ="XSpline\((.+)\)\n", current_line)

        line_to_strip =
        points = re.findall('(\(.*?\))', line_to_strip)
        for point in points:


here is my output:

Frames Per Second: 24.0
Source Width: 2048
Source Height: 778
Source Pixel Aspect Ratio: 1
Comp Pixel Aspect Ratio: 1
frame: 20

I want to figure out how to call out individual points given. For example, how would I have the code just spit out 0.793803, or just spit out 0.136326, etc etc

Thanks for your help in advance!


Member Avatar

Well, you have several tuples given as output - why not use a for loop to print each point inside that tuple? Or am I not understanding you correctly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.