Monthly Archives: June 2011

Render multiple scenes in one Folder (Windows)

In the rare case one has to render out multiple files instead of only the final file. I created a Python Script that will get the job done. (It automatically renders in Mental Ray)
The Script creates a BATCH-File that Renders out every file and saves it in the subfolder \img.

Update: Added “-of tga” to the Render output command to ensure that only Targa Files get created.

EDIT: This script only works for windows and in the System Environment Variables the Path to the Maya Renderer has to be set (e.g. C:\Program Files\Autodesk\Maya2012\bin).

import os
#Variables must be configured to the proper Path
projectName = "default"
path = os.environ['USERPROFILE'] + "\Documents\maya\projects" + "\\" + projectName + "\\" + "autosave"
#Camera selected
camera = "persp"

filename = "batchRender.bat"
fileoutput = path + "\\" + filename
file = open(fileoutput, "w")
file.write("@ECHO OFF")
file.write("TITLE Rendering AutoSaves")

outputpathCmd ="-rd " + path + "\img "

filelist = os.listdir(path)
filelist.remove(filename)

for item in filelist:
    outputimgNameCmd = "-im " + os.path.splitext(item)[0] + " "
    file.write("Render -r mr -of tga -cam " + camera + " " + outputimgNameCmd + outputpathCmd + path +"\\" + item)
    file.write("\n")

file.write("ECHO Batchrendering Completed \n")
file.write("ECHO Press Any Key to Finish... \n")
file.write("PAUSE")
file.write("DEL " + fileoutput)
file.close()

os.startfile(fileoutput)

Adding Floats in Python 2.6.x on Windows *Not Possibile*

So also Aufgabenblatt 7 von MMP – In den Folien ist ein ganz einfaches Beispiel wie man per update Methode ein Sprite bewegt . Man probiert das Beispiel mal aus und tadaa nichts funktioniert.

Nach etlichem herumprobieren und herumgooglen kommt man zu dem Ergebnis: Python 2.6.x kann unter Windows keine Float Zahlen korrekt addieren.

Wiedermal um die Aufgabe lösen zu können braucht man ein Alternatives Betriebssystem wie Ubuntu. (LMU-Studenten können sich einfach per NoMashine einloggen http://www.rz.ifi.lmu.de/Dienste/nx)

Weiterführendes zu dem Python Fehler:

http://stackoverflow.com/questions/4821941/python-nan-squared-error

http://www.mail-archive.com/relax-devel@gna.org/msg00337.html

Using the Brigde Tool with a Curve

The Bridge Tool allows to fill gaps between Edges. On both sides the same number of Edges must be selected to create a bridge. A very interesting feature of this tool is that it allows you to create the bridge along a curve.

To access this feature you open have to open the Options Dialog for the Tool and select “Smooth path + curve”. Now when you create a Bridge a Curve is created which controls the bridge. (Not visible in Shaded Mode)bridge options

I’ll start out by creating two Cubes spacing them out and delete two Faces. Then Mesh > Combine. bridge1

Then selecting the corresponding Edges to create the Bridge. Now in Wireframe Mode you can select the Control Vertex Points from the Curve and adjust them to your liking.

 

bridge2

You should get a similar result to this:

bridge final

Automatically set Default Settings for Maya

Usually one could simply store and recall the maya Preferences File. Here is a simple script if you want to enable certain default settings.

Python:

import maya.cmds as cmds
def nealDefaultSettings():
    #Disable View Cube
    cmds.viewManip(visible=False)

    #Disable Background Gradient
    cmds.displayPref(displayGradient=False)

    #Infinite Undo
    cmds.undoInfo( state=True, infinity=True )

    #Enable Autosave, max Versions 10, interval 15min
    cmds.autoSave(enable=True, maxBackups=10, interval=900)

    #Toggle Interactive Creation
    mel.eval('toggleCreateNurbsPrimitiveAsTool')
    mel.eval('toggleCreatePolyPrimitiveAsTool')

Update: Due to the Mel to Python cleanup the Mel Code has been removed.

Netbeans/JavaFX: “Error with Media: MediaError: media unsupported:com.sun.media.jmc.MediaUnsupportedException: Unsupported media”

Für die MMP Hausaufgabe Blatt 4 muss man ein MediaPlayer Objekt erstellen hierfür verwendet man folgenden Code (aus den Übungs Folien):

var audio1 = Media {
 onError: function(e: MediaError) {
 println("got a media error {e}");
 }
 source: "{path}a.mp3"
 };
 var mediaPlayer: MediaPlayer = MediaPlayer {
 media: audio1
 volume: 0.5
 autoPlay: false
 onError: function(e: MediaError) {
 println("got a MediaPlayer error : {e.cause} {e}");
 mediaPlayer.stop();
 mediaPlayer.media = null;
 }
 onEndOfMedia: function() {
 println("reached end of media");
 }
 };

Unter Netbeans 6.9.1 Wenn man versucht den Code auszuführen stößt man auf das Problem:
“Error with Media: MediaError: media unsupported:com.sun.media.jmc.MediaUnsupportedException: Unsupported media: (…).jar”

Das Problem lässt sich beheben indem man im Explorer den dazugehörigen Projektordner öffnet und der “build.xml” das folgende target-tag hinzufügt:

<!--?xml version="1.0" encoding="UTF-8"?-->

    Builds, tests, and runs the project MMP.

Update: Anscheinend funktioniert dieser Workaround nicht für alle Soundkarten – Falls es immer noch nicht funktionieren sollte würde ich den Code im Cip-Pool via Nomaschine testen (http://www.rz.ifi.lmu.de/Dienste/nx)