This is my rough notebook - I add information to it that I like to keep as reference.
Get link
Facebook
X
Pinterest
Email
Other Apps
Great trick for optimization so that code doesn't have to count size of array/list again and again. for (inti = 0, count = objectList.Count; i < count; i++) { ....... = objectList[i]; if (....) { ........ } }
Bounding Box in PIL(Python Image Library) : Bounding Box function of PIL can be very useful for removing unused pixels from an image. Eg. If we want to remove unused pixels based on alpha channel of an image, we can use following code. im = Image.open(imagePath) r,g,b,a = im.split() left,upper,right,lower = a.getbbox() tempImage = im.crop((left,upper,right,lower)) newPath = imagePath.split(".")[0]+"_Cropped" + "." + imagePath.split(".")[1] tempImage.save(newPath) To understand which values, getbbox() function returns and what do they look like on an image, I created an image showing the values returned by the function. left,upper,right,lower = image.getbbox() Suppose you have a point in an original image and you want to find out the new position of the same point in the cropped image, lets see how we can do it. Suppose the point is at (300,450) position in an original image, so after cr...
A very simple example for writing wrapper functions in Python. def polySphere(*args,**kwargs): try: return cmds.polySphere(*args,**kwargs) except: print "Could not create polySphere" print sys.exc_info() polySphere(r=5,sw=20,sh=20)
Step 1 : Install Eclipse Step 2 : Install PyDev Here is the easiest way of drag-n-drop : http://marketplace.eclipse.org/content/pydev-python-ide-eclipse Step 3 : Configure Python Interpreter Path to MayaPy's python interpreter : /Applications/Autodesk/maya2014/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python Extras : 1. For Autocompletion, add following line in "Forced Builtins" : maya.cmds,maya.mel,maya.standalone,maya.app,maya.OpenMaya,maya.OpenMayaAnim,maya.OpenMayaCloth,maya.OpenMayaFX,maya.OpenMayaMPx,maya.OpenMayaRender,maya.OpenMayaUI which will add following libraries : maya.cmds maya.mel maya.standalone maya.app maya.OpenMaya maya.OpenMayaAnim maya.OpenMayaCloth maya.OpenMayaFX maya.OpenMayaMPx maya.OpenMayaRender maya.OpenMayaUI Another Resource : http://sourceforge.net/p/pydev/discussion/293649/thread/fb1b2e45
Comments