Isotropix Forums

Vue camera exporter

Clarisse Scripting related topics

Vue camera exporter

Unread postby ruchirlives » Fri Jan 10, 2014 11:36 pm

I've had a shot at Python scripting a camera exporter from Vue 2014 to Clarisse 1.6 (PLE).
It's based on a modified exporter to Blender.
Seems to be working now. Would anyone be interested in trying or testing this?
ruchirlives
 
Posts: 8
Joined: Wed Mar 13, 2013 12:14 am

Re: Vue camera exporter

Unread postby support_team » Mon Jan 13, 2014 2:52 pm

Hi,

Cool! I guess the best is to post it in the forums.
Isotropix
Support Team
User avatar
support_team
 
Posts: 1024
Joined: Thu Jan 31, 2013 11:10 am

Re: Vue camera exporter

Unread postby ruchirlives » Mon Jan 13, 2014 11:53 pm

Ok. Hope this works.
To use run the script in VUE and save the generated .py file.
Open and run that .py file in a Clarisse script editor window.

Cheers, Ruchir.

Code: Select all
# =============================================================================================
# Name:                 VUE-Python Script to extract the camera animation from VUE to Clarisse
# Supported Versions:   VUE Infinite 2014 / Clarisse 1.6
# Tip:                  Import camera from VUE into Clarisse
# License:              This program is free software and licensed under the Ms-PL
# Author:               Ruchir Shah (c) 2014 based on a script by Andreas Pollak (c) 2011
# Versions:
# =============================================================================================
#
# Microsoft Public License (Ms-PL) (http://www.microsoft.com/opensource/licenses.mspx)
# ================================
# This license governs use of the accompanying software. If you use the software,
# you accept this license. If you do not accept the license, do not use the software.
#
# 1.Definitions
# The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same
# meaning here as under U.S. copyright law. A "contribution" is the original software, or any
# additions or changes to the software. A "contributor" is any person that distributes its contribution
# under this license. "Licensed patents" are a contributor's patent claims that read directly on its contribution.
#
# 2.Grant of Rights
# (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
#     each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution,
#     prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
# (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each
#     contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made,
#     use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of
#     the contribution in the software.
#
# 3.Conditions and Limitations
# (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
# (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
#     patent license from such contributor to the software ends automatically.
# (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
#     notices that are present in the software.
# (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
#     a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
#     object code form, you may only do so under a license that complies with this license.
# (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
#     or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
#     permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
#     purpose and non-infringement.
#
# USAGE INSTRUCTIONS
# ==================
# 1.) Load your scene in VUE
# 2.) Store this script somewhere on your disc f.e "C:\Users\<YourName>\Scripts\VUE\ExportVUECameraToClarisse.py"
# 3.) Open the script in a texteditor like Notepad.exe or similar and find the TODO below. Change the path to the
#       result. Files get overwritten without prior warning.
#       Save the script to disc.
# 4.) In VUE select menu: Automation - Display Console (This will allow you to see eventual errors in the script)
# 5.) In VUE select menu: Automation - Run Python Script...
# 6.) Select the script "C:\Users\<YourName>\Scripts\VUE\ExportVUECameraToClarisse.py"
# 7.) The result file will be written in the given folder
# 8.) Open Clarisse and load your scene.
# 9.) Span up a new window by dragging the right upper corner ino the view.
# 10.) Switch the View to "Script"
# 11.) Open the resulted pythonscript
# 12.) Click on the "run" button. A new camera will be generated and keyframes set accordingly. Start and end of animation will
#       also be changed.
# -----------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------




# File Browser code
def filescript():

    from Tkinter import Tk
    from tkFileDialog import asksaveasfilename

    options={}
    options['filetypes'] = [('Python script files', '.py')]
    options['defaultextension'] = '.py'

    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    myDestinationFileName = asksaveasfilename(**options) #

    if myDestinationFileName!="":
        print("Found it")
        camscript(myDestinationFileName)
    else:
        print("No file")

    return


def camscript(myDestinationFileName):

    resx=PictureWidth()
    resy=PictureHeight()

    vuesensorhoriz=35.975130221963276 / 1000 #mm to metres
    vuesensorvert=float(resy)/resx*vuesensorhoriz

    # We use the camera the user selected
    SelectByType(VuePython.VOT_Camera)
    selectedObject = GetSelectedObjectByIndex(0)
    cameraToExport = selectedObject.ToCamera()

    # We export each frame from start to end
    startFrame = StartFrame()
    endFrame = EndFrame()
    SetCurrentFrame(startFrame)
    GetSceneAtCurrentTime()

    currentFrame = CurrentFrame()
    previousFrame = currentFrame - 1;
    print('Processing... :%s ' %currentFrame)

    # Now write the script
    ixScript=open (myDestinationFileName,'w')

    ixScript.write('# =========================================================================\n')
    ixScript.write('# Name:         Generated Script to create Vue Camera in Clarisse\n')
    ixScript.write('# License:      This program is free software and licensed under the Ms-PL\n')
    ixScript.write('# Author:       Ruchir Shah (c) 2014 modifying a script by Andreas Pollak (c) 2011\n')
    ixScript.write('# =========================================================================\n\n')

    ixScript.write('import math \n')
    ixScript.write('\n')


    # Create camera
    ixScript.write('print(" === Create a new Camera in the scene === ") \n')

    ixScript.write('oScene = ix.application.get_builtin_commands() \n')
    ixScript.write('oScene.set_current_frame_range(%s, %s) \n' %(startFrame, endFrame))
    ixScript.write('ix.set_current_frame(%s) \n' %startFrame)

    ixScript.write('newCamera = ix.create_object(\'camera\', \'CameraPerspectiveAdvanced\') \n')

    # Scene details


    curFocal=cameraToExport.Focal()/1000 #mm to metres
    ixScript.write('newCamera.attrs.horizontal_aperture = %f \n' %vuesensorhoriz)
    ixScript.write('newCamera.attrs.vertical_aperture = %f \n' %vuesensorvert)
    ixScript.write('newCamera.attrs.focal_length = %f \n' %curFocal)

    # Loop through Animation of camera

    for frame in range(int(startFrame),int(endFrame)+1):
        currentFrame = frame
        SetCurrentFrame(currentFrame)
        GetSceneAtCurrentTime()
        currentFrame = CurrentFrame()
        print('Processing Frame:%s ' %currentFrame)

        curPosition=cameraToExport.Position()
        curRotation=cameraToExport.GetRotationAngles()
        curFocusDistance=cameraToExport.FocusDistance ()
        curShiftX=cameraToExport.HorizontalFilmShift()
        curShiftY=cameraToExport.VerticalFilmShift()

        ixScript.write('\n')
        ixScript.write('\n')

        ixScript.write('ix.set_current_frame(%s) \n' %currentFrame)

        x= (curRotation[0]-90)*-1
        y= (curRotation[2]-180)
        z= curRotation[1]

        ixScript.write('newCamera.attrs.rotate[0]=%f \n' %x)
        ixScript.write('newCamera.attrs.rotate[1]=%f \n' %y)
        ixScript.write('newCamera.attrs.rotate[2]=%f \n' %z)

        x= curPosition[0]
        y= curPosition[2]
        z= curPosition[1]*-1

        ixScript.write('newCamera.attrs.translate[0]=%f \n' %x)
        ixScript.write('newCamera.attrs.translate[1]=%f \n' %y)
        ixScript.write('newCamera.attrs.translate[2]=%f \n' %z)

    #   ixScript.write('newCamera.data.dof_distance = %f \n' %curFocusDistance)
    #   ixScript.write('newCamera.data.shift_x = %f \n' %curShiftX)
    #   ixScript.write('newCamera.data.shift_y = %f \n' %curShiftY)
        ixScript.write('\n')


    #   Set keys for translations and rotations
        ixScript.write('for i in range(0,3): \n')
        ixScript.write('   oScene.set_key("%s.translate[%s]" %(newCamera,i))')
        ixScript.write('\n')
        ixScript.write('\n')


        ixScript.write('for i in range(0,3): \n')
        ixScript.write('   oScene.set_key("%s.rotate[%s]" %(newCamera,i))')
        ixScript.write('\n')
        ixScript.write('\n')


    ixScript.write('ix.set_current_frame(%s) \n' %startFrame)
    SetCurrentFrame(startFrame)
    ixScript.close()

    Refresh ()

    return

#Execute scripts
filescript()
ruchirlives
 
Posts: 8
Joined: Wed Mar 13, 2013 12:14 am


Return to Scripting