Re-wrote my free selection-set creation script, 'ld_selectMe' in python.
Updates include a more dynamic UI, faster set creation and overall, a much better write of the actual selection script, allowing the same functionality but only much, much faster than its mel counterpart.
You can download the re-write for free here (mediafire.com)
or creativecrash here.
Any comments/suggestions welcome.
Friday, 13 April 2012
Tuesday, 3 April 2012
Friday, 30 March 2012
Python: Writing nested dictionaries to file
Best suggestion I could think of was using cPickle (if available).
However im all for cPickle.
try: import cPickle as pickle except: import pickle # nested DICTIONARY data = { 'one': {'label': 'This is shot 001', 'start': 1, 'end': 10}, 'two': {'label': 'This is shot 002', 'start': 11, 'end': 25}, 'three': {'label': 'This is shot 003 - Needs Editing', 'start': 26, 'end': 50} } # write to file with cPickle/pickle (as binary) def ld_writeDicts(filePath,dict): f=open(filePath,'w') newData = pickle.dumps(dict, 1) f.write(newData) f.close() ld_writeDicts('C:/Users/Lee/Desktop/test2.dta',data) ############# # read file decoding with cPickle/pickle (as binary) def ld_readDicts(filePath): f=open(filePath,'r') data = pickle.load(f) f.close() return data # return dict data to new dict newDataDict = ld_readDicts('C:/Users/Lee/Desktop/test2.dta') # test nesting print newDataDict['one']['label']As you can see its very simple to use and very quick. There are loads of alternatives if you wanted a nicely arranged, readable file, including json:
import json # nested DICTIONARY data = { 'one': {'label': 'This is shot 001', 'start': 1, 'end': 10}, 'two': {'label': 'This is shot 002', 'start': 11, 'end': 25}, 'three': {'label': 'This is shot 003 - Needs Editing', 'start': 26, 'end': 50} } # write to file with json encoding def ld_writeDicts(filePath,dict): f=open(filePath,'w') newData = json.dumps(dict, sort_keys=True, indent=4) f.write(newData) f.close() ld_writeDicts('C:/Users/Lee/Desktop/test',data) # read file decoding with json def ld_readDicts(filePath): f=open(filePath,'r') data = json.loads(f.read()) f.close() return data # return dict data to new dict newDataDict = ld_readDicts('C:/Users/Lee/Desktop/test.dta') # test nesting print newDataDict['one']['label']
However im all for cPickle.
Labels:
cPickle,
dictionaries,
files,
folders,
json,
maya,
nested dictionaries,
pickle,
python,
Resources,
scripting,
write to file
Thursday, 15 March 2012
Mel: Invert Selection from a render layer
Thought I might post up this useful code someone asked for...
It'll invert the selection for whatever visible transform objects are in the current render layer. Its not fantastic but it was a 5-minute job.
// ld_invertSel_rlyr.mel 0.2 // // Authors: Lee Dunham // Licence: Creative Commons, Attribution, Share Alike // About: Inverts selection for visible objects in current render layer. // Usage: // ld_invertSel_rlyr ; global proc ld_invertSel_rlyr(){ string $currentRenderLayer=`editRenderLayerGlobals -q -currentRenderLayer` ; string $objsRenLayer[]=stringArrayRemoveDuplicates(`editRenderLayerMembers -q $currentRenderLayer`) ; for($obj in $objsRenLayer) if(`getAttr ($obj+".v")`==1 && `objectType -isType "transform" $obj`) select -tgl $obj ; else select -d $obj ; }
It'll invert the selection for whatever visible transform objects are in the current render layer. Its not fantastic but it was a 5-minute job.
Labels:
invert selection,
maya,
mel,
render layers,
scripting
Wednesday, 14 March 2012
ld_mirrorMe v1.5.0
Edit: Source is now available on GitHub.
Alongside my softCluster script, you'll definitely notice a speed increase in your workflow.
Download it here (mediafire link).
Download, extract and place script in maya's script directory and use
import ld_mirrorMe ld_mirrorMe.GUI()
It's features are shown on this much quicker demo (v1.0.0), supporting multi-mirroring for all modes.
Full details:
- 3 modes:
1. Curve - mirrors nurbs curves, ideal for mirroring rig controls,
2. Mesh - mirrors geo, ideal for mirroring blendshape targets,
3. Deformer - mirrors only clusters (at present), uses object's pivot for mirroring.
- multi-mirroring on all 3 modes,
- choose mirror axis,
- search and replace,
- alter new objects position (currently either world 0, target, mirror or original - depending on mode),
- world position/rotation based, will work wherever or whatever the targets connected to,
- entry objects names retained, if multiple copies needed (ideal for multi-clustering),
- colourize option for Curves, if given curve is coloured (transform or shape), its mirror can be assigned a different colour,
- quick and simple to use.
Updates:
09/03/12 - 0.5.0
Initial working version.
10/03/12 - 0.9.5
Tidied UI and reduced/cleaned code.
13/03/12 - 1.0.0
Added colour option for curves.
Removed all pymel (speed issues).
Allowed multi-mirroring.
14/03/12 - 1.5.0
Thanks to Matt Murray for feedback for further improvements.
Added option to mirror world position of mirrored curve.
Added further error-checking for all modes.
Fixed bug causing unwanted locking of attributes.
Added option to disable colouring of mirrored curve.
Again, any feedback, problems/bugs or ideas lemmie know and I'll do what I can.
Saturday, 10 March 2012
ld_mirrorMe tool demo
Just made a quick demo for one of my 3 main toolsets, (ld_animateMe v2, ld_rigMe v1 and ld_mirrorMe v.9.5) the ld_mirrorMe tool, something I started a while ago but put off.
This demo primarily shows mirroring on objects from world 0, but everything is calculated from worldspace and works accordingly, it doesn't matter where it is or what its connected/parented to, the mirror will work as expected.
Details:
3 modes - Curve, Mesh and Cluster (at present),
- Curve - Primarily for mirroring nurbs curves for controllers, Mesh - Primarily for mirroring blendshapes (can mirror multiple targets at the same time), and Cluster - (developing for other deformers), given a deformer and its mesh will mirror the deformer over giving a correctly mirrored pivot and origin based on the objects pivot.
Search and replace feature,
Choose mirror axis,
Choose new objects position,
World based - will work wherever or whatever the targets connected to,
Entries retained, no need to keep adding same object of multiple copies needed,
Simple to use.
This was initially going to just be a tool for my rigging UI (ld_rigMe), but I prefer having it separate.
Any ideas/comments welcome.
This demo primarily shows mirroring on objects from world 0, but everything is calculated from worldspace and works accordingly, it doesn't matter where it is or what its connected/parented to, the mirror will work as expected.
Details:
3 modes - Curve, Mesh and Cluster (at present),
- Curve - Primarily for mirroring nurbs curves for controllers, Mesh - Primarily for mirroring blendshapes (can mirror multiple targets at the same time), and Cluster - (developing for other deformers), given a deformer and its mesh will mirror the deformer over giving a correctly mirrored pivot and origin based on the objects pivot.
Search and replace feature,
Choose mirror axis,
Choose new objects position,
World based - will work wherever or whatever the targets connected to,
Entries retained, no need to keep adding same object of multiple copies needed,
Simple to use.
This was initially going to just be a tool for my rigging UI (ld_rigMe), but I prefer having it separate.
Any ideas/comments welcome.
Wednesday, 7 March 2012
Python: Create Cluster from soft selection
Edit: Source now available on GitHub.
or from creativecrash here.
All thanks to Brian Escribano for his softSelection() code that gathers the id and weights of the current soft selection (basically, all the hard work).
It was simple enough to apply that information to a new cluster.
Usage:
Extract and place script file into a maya script directory (or python path directory) and run with this
import ld_createSoftCluster as sc sc.ld_createSoftCluster()
and thanks to Valen Wagner for the icon.
Update:
07/03/12 - 0.4.0
Alters cluster position to match selection rather than influenced average.
Labels:
cluster,
downloads,
maya,
python,
scripting,
soft selection,
soft selection to cluster
Subscribe to:
Posts (Atom)