# two lists with some matching entries
a=['jon','mary','frank']
b=['lewis','frank','jon','clive','betty','toni','jim']
#typical method using for loop with if/in statement
results=[]
for i in a:
if i in b:
results.append(i)
print results
# with list comprehension
results=[x for x in a if x in b]
print results
Thursday, 5 January 2012
Using Python list comprehension
Just a quick example of how I use list comprehension to search for matching entries in two lists (of course there's x amount of ways to do this, and results will vary depending on usage).
Labels:
list comprehension,
lists,
match,
python,
scripting
Adding notes to nodes in Maya through mel
Its fairly straightforward to add notes to a node in Maya (under Attribute Editor, add text to under Notes section), but through mel there's one more step you need to go through before you can.
Simply put, the node needs a "notes" (or s/n "nts") attribute first, then its plain sailing (manually writing a note creates the attr, which then stores the string - or so im assuming, looks like that's handled through a scriptJob)
So to add a note to a node, first check whether it already has an attribute called "notes", create one if not, then write something.
string $node[]=`polyCube` ;
if(!`attributeQuery -node $node[0] -ex "notes"`)
addAttr -ln "notes" -sn "nts" -dt "string" $node[0] ;
setAttr -type "string" ($node[0]+".notes") "This node now has a Note. You can store various bits of information here." ;
(The note on this script example is on the transform node of the polyCube object ($node[0]) as $node[1] would be the shape object)
Wednesday, 4 January 2012
Iconicles VFX Showreel
My work includes;
All Character/Prop Rigs, as well as - Animation, Dynamics, Animation Tools and Pipeline Development/Tools.
Still sorting current showreel, will be up asap.
Selecting animated objects
Quick little script for selecting any (dag) objects with animation on.
I was already aware that mel doesn't need curly brackets "{}" following if statements or for loops (will only execute the next line of code), it seems that it doesn't need them even if your incorporating another statement or loop :) such as the above code shows...
string $allObjects[]=`ls` ;
select -cl;
for($i=0;$i<`size($allObjects)`;$i++)
if(`keyframe -q -keyframeCount $allObjects[$i]` != 0)
select -tgl $allObjects[$i] ;I was already aware that mel doesn't need curly brackets "{}" following if statements or for loops (will only execute the next line of code), it seems that it doesn't need them even if your incorporating another statement or loop :) such as the above code shows...
Tuesday, 3 January 2012
Toggle lighting script
simple script to toggle the lighting between "default" and "use all lighting" on the current panel.
string $currentPanel=`getPanel -withFocus` ;
string $mode="default" ;
if(`getPanel -to $currentPanel`=="modelPanel")
if(`modelEditor -q -dl $currentPanel`=="default")
$mode="all" ;
modelEditor -edit -dl $mode $currentPanel ;
Monday, 12 December 2011
Maya 2012: Changing channelBox decimal places (precision)
Most maya users know that you can use more decimal places then Maya displays by default.
For example, it is possible to translate an object by 1.11111 although maya will display "1.111".
When you use getAttr, it will return the correct values, but to display in the channel box, very simply under Edit in the channelBox go settings -> Change Precision...
Simple as, decimal places range from 1 to 15.
For example, it is possible to translate an object by 1.11111 although maya will display "1.111".
When you use getAttr, it will return the correct values, but to display in the channel box, very simply under Edit in the channelBox go settings -> Change Precision...
Simple as, decimal places range from 1 to 15.
Friday, 9 December 2011
Outlook 2010 - Filter e-mails between specific dates
Sounds to be much simpler than it should be (tbh only really searched for a few minutes), but...
Say you want to filter your emails between dates?
Atm, a specific date was easy enough, but between dates seemed more hassle and the only way I could see was to create a new search filter.
Under "Search" tab, search Tools -> Advanced Find, then "Advanced" tab - and under Define more criteria dropdown select "Date/Time Fields" -> "Received", Condition to "Between", and Value to "<start Date> and <end Date>" then under "Browse", make sure you check "Include Subfolders", then "Find Now".
It was a pain in the ass, and would love to hear a simpler way of doing it...
Say you want to filter your emails between dates?
Atm, a specific date was easy enough, but between dates seemed more hassle and the only way I could see was to create a new search filter.
Under "Search" tab, search Tools -> Advanced Find, then "Advanced" tab - and under Define more criteria dropdown select "Date/Time Fields" -> "Received", Condition to "Between", and Value to "<start Date> and <end Date>" then under "Browse", make sure you check "Include Subfolders", then "Find Now".
It was a pain in the ass, and would love to hear a simpler way of doing it...
Subscribe to:
Posts (Atom)