mayaScript

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 default settings.

import pymel.core as pm

def manage_Default_options(**kwargs):
    """
    Sets Various Default options for Maya
    
    viewmManip : Default Hide the manipulator Cube
    gradient: Default Hide the Background gradient
    autosave: Default Enable Autosave
    mentalray: Default Enable mr as Default Render Engine
    interactiveCreation: Enables Disables Interactive Creation Mode for Primitive Objects
     
    hardware2: Optional Enable Hardware Renderer 2.0 as Default Render Engine
    
    """
    
    #Disable View Cube
    pm.viewManip(visible=kwargs.get("viewManip", False))
    
    #Disable Background Gradient
    pm.displayPref(displayGradient=kwargs.get("gradient", False))
    
    #Infinite Undo
    pm.undoInfo(state = True, infinity = kwargs.get("infiniteUndo", True))
    
    #Enable Autosave, max Versions 10, interval 15min
    pm.autoSave(enable=kwargs.get("autosave", True), maxBackups=kwargs.get("maxBackups", 10), interval=kwargs.get("interval", 900))
    
    #Activate Mental Ray
    if (kwargs.get("mentalray", True)): enable_mr_plugin()
    
    #Sets Hardwarerenderer 2.0 as Default
    if (kwargs.get("hardware2", False)): pm.PyNode("defaultRenderGlobals").currentRenderer.set("mayaHardware2")
    
    #Expose Mental Ray Production Nodes
    pm.optionVar["MIP_SHD_EXPOSE"] = 1
    
    #Disable Interactive Creation
    setInteractiveCreation(kwargs.get("interactiveCreation", False))
    

def setInteractiveCreation(enabled = False):
    """
    Enables or Disables Interactive Creation
    """
    pm.optionVar['createNurbsPrimitiveAsTool'] = enabled;
    pm.ui.CommandMenuItem("MayaWindow|mainCreateMenu|menuItem285|toggleCreateNurbsPrimitivesAsToolItem").setCheckBox(enabled)
    
    pm.optionVar['createPolyPrimitiveAsTool'] = enabled;
    pm.ui.CommandMenuItem("MayaWindow|mainCreateMenu|polyPrimitivesItem|toggleCreatePolyPrimitivesAsToolItem").setCheckBox(enabled)
    
def enable_mr_plugin():
    """
    loads and sets the mental Ray Plugin as default
    """
    loadPlugin('Mayatomr')
    pm.PyNode("defaultRenderGlobals").currentRenderer.set("mentalRay")
    print ('# Result: mental ray Plugin loaded #')
    

def loadPlugin(pluginName):
    """
    if the plugin is not loaded, it is loaded and set to autoload
    
    pluginName: name of the plugin to be loaded
    """
    if not pm.pluginInfo(pluginName, q=True, loaded=True):
        pm.loadPlugin(pluginName)
        pm.pluginInfo(pluginName, edit=True, autoload=True)
    
maya2014-wireframe

Maya 2014: Wireframe Rendering using Mental Ray

Wireframe images have a very clean and technical look, frankly they look awesome. Here and then you need wireframe images for GUI elements or graphical work.

A quick way to render wireframe images is to use mental rays “contour” feature.

Render Settings

  1. Navigate to the “Features”-tab
  2. Scroll down and expand “Contours”
  3. Enable “Enable Contour Rendering”
  4. Expand the “Draw by Property Difference”-section
  5. Enable “Around all Poly Faces” 

Note: If you do not enable any draw method, no contour lines are going to be drawn even if “Enable Contour Rendering” has been activated.

wireframe-rendersettings1

Maya 2014 Settings

As default in Maya 2014 mental ray renders with the new “Unified Sampling”-method. This method does not support Contour rendering. (Prior versions are not effected)

In the Quality-tab, in the Sampling section, enable “Legacy Sampling Mode” to be able to render the contour lines. (Max Sample Level 2)

wireframe-rendersettings2

Material Settings

  1. First create a white Lambert material “mat_wireframe”
  2. Navigate to the Shading Group, for example: “lambert2SG”, and rename it to “mat_wireframeSG”
  3. Expand the mental ray section, and the subsection “Contours”
  4. Enable “Contour rendering”, and set the color to black.
  5. Apply the material to a testobject and do a render.
  6. If necessary adjust the value of the width (0.5 usually has nice results)
    MaterialSettings

Now simply apply the material to the objects that you would like to render as wireframe.

Note: if you render objects with “smooth mesh preview” enabled (By pressing the Key 3), mental ray renders a more complex wireframe. In such cases selecting the object and pressing the key 1 enables mental ray to render out the low poly version.

Windows Logo reworked

Windows: Autoinstall Programs using Ninite Powershell Script

Ninite provides a quick way to install multiple applications.
The list of packages is available directly on the site.

win_autoinstall_ninite.ps1:

Write-Host Ninite autoinstall
#Get item names by reading ninite.exe download url
$items = @(".net", 
"7zip", "avast", "chrome","dropbox", 
"eclipse", "filezilla", "imgburn", "itunes", 
"java", "notepadplusplus", "skydrive", "skype", 
"steam", "teracopy", "thunderbird", "utorrent", "vlc", "winamp")

#Create URL
foreach ($item in $items)
{ $url += $item + "-"
}
$url = "http://www.ninite.com/" + $url.TrimEnd("-") + "/ninite.exe"

#Download 
$file = [system.environment]::getenvironmentvariable("userprofile") + "\Downloads\ninite.exe"
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url,$file)

& $file

#If you have access to the Pro version of ninite it is possible to use the silent trigger instead
#& $file /silent


  

Install command using github repository:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://gist.github.com/borgfriend/5763637/raw/911328f3af4b75294d490a3e012b408c6c535c7c/win_autoinstall_ninite.ps1'))

The only downside of the script is that you have to click once close. So well its not completely silent. However the professional version of ninite would allow for such functionality.
The installer could also for example only install “.net” and the rest of the packages could be installed using chocolatey.

Windows Logo reworked

Windows: Autoinstall Programs using Chocolatey Script

Chocolatey, is a project that allows package installation similar to the apt-get method in Linux using Powershell. So in essence download and install software using the command line.

A list of packages is available here. However anyone can create and upload a new package (hence you have no idea if viruses or other unwanted ad-ware are included in the package)

As prerequisite you need to install Net4.0. This installation of Net4.0 is not handled by Chocolatey. Adding an additional step in the deployment process. (Download .Net4.0)

In addition the syntax of the “cinst”-module does not allow to install multiple packages simultaneously. However it is possible to create a xml-file defining the packages.

Example packages.config:


<!--?xml version="1.0" encoding="utf-8"?-->
<packages>
	<package id="GoogleChrome/">
	<package id="thunderbird/">
</packages>

The xml file creation could be handled by Powershell. So I created a simple script for Powershell to handle automated installation of packages.

win_autoinstall_chocolatey.ps1:

This script can only be run if Net4.0 is installed.

#########################
# Autoinstall script using chocolatey
#########################
# Note: Net 4.0 must be installed prior to running this script
#
#Modify this line to change packages
$items = @("GoogleChrome", "thunderbird", "skype", "vlc", "quicktime", "flashplayerplugin", "javaruntime", "DotNet4.5", "utorrent", "dropbox", "Teracopy", "7zip.install", "python", "eclipse-java-juno", "notepadplusplus.install", "git.install" )
 
 
 
#################
# Create packages.config based on passed arguments
#################
$xml = '<?xml version="1.0" encoding="utf-8"?>'+ "`n" +'<packages>' + "`n"
foreach ($item in $items)
{
  $xml += "`t" +'<package id="' + $item + '"/>' + "`n"
}
$xml += '</packages>'
 
$file = ([system.environment]::getenvironmentvariable("userprofile") + "\packages.config")
$xml | out-File $file
 
####
# Install chocolatey
####
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
 
 
######
# Install packages with cinst
######
 
cinst $file
 
 
########
# Delete packages.config
Remove-Item $file

The script is hosted on github and can be integrated into a batch file with following command:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://gist.github.com/borgfriend/5727365/raw/909e443563af26d4797d8296cc49ebd8d472acc9/win_autoinstall_chocolatey.ps1'))

Overall it is a very interesting project. However the Net 4.0 prerequisite should be included in the Chocolatey install procedure (However now an extra step to install .Net4.0 is required and that does not allow for a fully automated process) and due to the fact that anyone can upload packages to the Chocolatey repository in some cases there could be security concerns.

maya_ubuntu logo

Ubuntu 13.04: Maya 2014 Install script

#!/bin/bash
#Heith Seewald 2012
#Feel free to extend/modify to meet your needs.
#Maya on Ubuntu v.1
#This is the base installer... I’ll add more features in later versions.
#if you have any issues, feel free email me at heiths@gmail.com
 
#this version is updated by insomniac_lemon... issues were fixed and it has been converted to 2014, use at your own risk... 
#testing in a VM first is recommended... (at least until I test it again or someone confirms it works without tinkering)

#this version is updated by borgfriend... tested on ubuntu 13.04 (fresh install virtual box)
#changed Libcrypto libssl linking
#updated versionnumbers of libtiff, libjpeg
 
#### Lets run a few checks to make sure things work as expected.
#Make sure we’re running with root permissions.
if [ `whoami` != root ]; then
    echo Please run this script using sudo
    echo Just type “sudo !!”
    exit
fi
#Check for 64-bit arch
if [uname -m != x86_64]; then
    echo Maya will only run on 64-bit linux. 
    echo Please install the 64-bit ubuntu and try again.
    exit
fi
 
#Setup a few vars
export MAYAINSTALL='mayaTempInstall'
export RPM_INSTALL_PREFIX=/usr
export LD_LIBRARY_PATH=/opt/Autodesk/Adlm/R5/lib64/

MAYAURL="http://trial.autodesk.com/SWDLDNET3/2014/MAYA/ESD/Autodesk_Maya_2014_English_Linux_64bit.tgz"
 
#Install Message
echo "You’re about to download and install Autodesk Maya 2014"
echo ""
echo "Do you wish to continue [Y/n]?"
read RESPONSE
case "$RESPONSE" in
	n*|N*)
	echo "Install Terminated"
	exit 0;
esac
 
#Get serial number
echo "If you have not already done so, you can get your serial number from: http://students.autodesk.com"
echo "Enter the serial number"
read SERIALNUMBER
echo ""
 
#Create a temp folder for the install files 
if [ ! -d "$HOME/mayaInstaller" ]; then
	mkdir $HOME/$MAYAINSTALL
	echo "Creating $MAYAINSTALL folder"
	echo ""
fi
export INSTALLDIR=$HOME/$MAYAINSTALL
cd $INSTALLDIR
 
#Get Maya
wget --referer="http://trial.autodesk.com" --content-disposition $MAYAURL
 
 
 
# Install Dependencies
#I changed this a bit because for some reason alien would never install for me
#also note -y was added so you can leave the script alone and not having it snag on asking for user input
#well, the MS agreement will still stop it :(
sudo apt-get install -y alien
sudo apt-get install -y csh tcsh libaudiofile-dev libglw1-mesa elfutils
sudo apt-get install -y gamin libglw1-mesa-dev mesa-utils xfs xfstt 
sudo apt-get install -y ttf-liberation xfonts-100dpi xfonts-75dpi
sudo apt-get install -y ttf-mscorefonts-installer
sleep 3s
 
#This is in case of name change (due to new service pack or something)
MAYAFILE=Autodesk*.tgz
# Extract Maya Install Files
tar xvf $INSTALLDIR/$MAYAFILE
 
 
#prevents composite from messing up your system.... (it happened to me with 2013, I had to re-install...)
rm $INSTALLDIR/Composite*
 
# Convert rpms to debs
for i in $INSTALLDIR/*.rpm; do
  sudo alien -cv $i;
done
sleep 2s
 
#again, space saving step.
sudo rm $INSTALLDIR/*.rpm
 
#install the debs
sudo dpkg -i $INSTALLDIR/*.deb
 
#Setup For Mental Ray.
sudo mkdir /usr/tmp
sudo chmod 777 /usr/tmp
 
#font issue fix
xset +fp /usr/share/fonts/X11/100dpi/
xset +fp /usr/share/fonts/X11/75dpi/
 
#fixing a few lib issues
sudo cp $INSTALLDIR/libadlmPIT* /usr/lib/libadlmPIT.so.7
sudo cp $INSTALLDIR/libadlmutil* /usr/lib/libadlmutil.so.7
 
# License Setup:
sudo echo -e 'MAYA_LICENSE=unlimited\nMAYA_LICENSE_METHOD=standalone' > /usr/autodesk/maya2014-x64/bin/License.env
#Notice the lack of sudo.
/usr/autodesk/maya2014-x64/bin/adlmreg -i S 657F1 657F1 2014.0.0.F $SERIALNUMBER /var/opt/Autodesk/Adlm/Maya2014/MayaConfig.pit
 
# libtiff
sudo ln -s /usr/lib/x86_64-linux-gnu/libtiff.so.5 /usr/lib/libtiff.so.3

sudo apt-get install libjpeg62:i386
#libjpeg
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2 /usr/lib/libjpeg.so.62

sudo ln -s /usr/autodesk/maya2014-x64/support/openssl/libssl.so.6 /usr/autodesk/maya2014-x64/lib/libssl.so.10
sudo ln -s /usr/autodesk/maya2014-x64/support/openssl/libcrypto.so.6 /usr/autodesk/maya2014-x64/lib/libcrypto.so.10
sleep 2s

sudo maya
ubuntu logo

Ubuntu 13.04: Autosetup script

So I am dabbling around with Linux once again. Apperantly in the new version of Ubuntu Amazon has placed some ads in the search feature. Here is my script to remove the ads as well as install some programs that I use.

#!/bin/sh
###############################################
# Ubuntu 13.04 AutoSetup script 
# Author: Neal Buerger (www.nealbuerger.com)
################################################
#
# Installs Eclipse, VLC, Chrome, Skype
# Removes Games, Amazon Search Integration, Ubuntu One, Rhythmbox, Firefox
# Updates all Packages
#
###############################
#To run script 
# 
# add executable permission to file:
# chmod +x autosetup.sh
# Run Script with:
# sudo ./autosetup.sh
###############################

########################
# Install Applications #
########################
printf "Eclipse \n"
sudo apt-get install -y eclipse

printf "vlc \n"
sudo apt-get install -y vlc

printf "Chrome \n"
sudo apt-add-repository -y 'deb http://dl.google.com/linux/chrome/deb/ stable main' 
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
sudo apt-get install -y google-chrome-stable

printf "Skype \n"
wget http://www.skype.com/go/getskype-linux-beta-ubuntu-64
sudo dpkg -i getskype-*
sudo apt-get -f install

##################
#remove packages #
##################
printf "remove games \n"
sudo apt-get remove -y --purge aisleriot gnome-sodoku gnome-mines

printf "remove amazon integration"
sudo apt-get remove -y unity-lens-shopping

printf "remove ubuntu one"
sudo apt-get remove -y ubuntuone-client-proxy ubuntuone-control-panel-qt ubuntuone-client-gnome
sudo apt-get purge -y ubuntuone-client python-ubuntuone-storage*
sudo apt-get remove -y rhythmbox-ubuntuone

printf "remove rhythmbox"
sudo apt-get remove -y rhythmbox

#remove firefox
sudo apt-get -y purge firefox firefox-globalmenu firefox-gnome-support


##################
# update dist    #
##################
sudo apt-get update
sudo apt-get -y dist-upgrade