[ create a new paste ] login | about

Link: http://codepad.org/2ree0mMM    [ raw code | fork ]

Python, pasted on May 17:
import c4d
from c4d import storage

def main():
    data = ['']  # empty list
    selection = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN) # selected objects in the document -> list
    
    path = c4d.storage.SaveDialog(type = c4d.FILESELECTTYPE_ANYTHING, force_suffix = 'txt') # ask for path
    
    for obj in selection: #loop selection
        if obj.CheckType(c4d.Ocamera): # check for cam
            tag = obj.GetTag(c4d.Ttargetexpression) # get target expression
            target = 'None'
            if tag:
                tobj = tag[c4d.TARGETEXPRESSIONTAG_LINK]
                if tobj: target = shortVec(tobj.GetMg().off)
            # add string name, pos, focus, target.pos
            data.append('{1} {3} {4}\n'.format(obj.GetName(), 
                                                       shortVec(obj.GetMg().off), 
                                                       obj[c4d.CAMERAOBJECT_TARGETDISTANCE],
                                                       target,
                                                       obj[c4d.CAMERA_FOCUS]))

    with open(path, 'w+') as f: # save to file
        for string in data:
            f.write(string)


# little helper method for a short vector repr
def shortVec(vector):
    return '{0} {1} {2}'.format(vector.x,vector.y,vector.z) 

if __name__=='__main__':
    main()


Create a new paste based on this one


Comments: