Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Undo Group Mismatch

$
0
0

I am just learning AE Scripting, and this is my first script. It took a while, and I eventually got it to do what I wanted it to, but I am now having an issue with the Undo Group. When I run the script it gives me an 'Undo Group Mismatch' and fails to completely undo the actions in the script. I'm afraid I'm not knowledgeable enough to determine the source of the problem. I'd appreciate any help.

 

The script creates a solid, applies the Gradient Ramp, then Copies it with Property Links, Pastes it, then pre-comps the copy. Then on the master solid it adds a camera blur, sets the pre-comp to the blur layer, and hides the main gradient ramp effect. The idea being I can still control the ramp from the main timeline and it is mirrored in the pre comp. Here's the script:

 

  1. /* DOF script
  2. Make a solid called 'DOF_Master'
  3. Apply Gradient Ramp
  4. Copy With Properties
  5. Paste as 'DOF_Slave'
  6. Pre-Comp as 'DOF_Slave Comp'
  7. Move Slave to bottom of layer stack
  8. To Master: Apply Camera Blur
  9. Turn Gradient Ramp off
  10. Select slave Comp as Blur Layer
  11. Set as  Adjustment layer
  12. */
  13. app.beginUndoGroup("DOF with Precomped Gradient");
  14. function createDOF(){
  15. // variables
  16. var myComp = app.project.activeItem; 
  17. if(myComp == null){alert("Please, select your composition"); return false;}
  18. var slaveIndex
  19. var w = myComp.width ;
  20. var h = myComp.height ;
  21. // create solid at comp dimensions
  22. myComp.layers.addSolid([1.0,1.0,0], "DOF_Master", w, h, 1);
  23. // Apply Ramp and Camera Blur filters
  24. myComp.layer("DOF_Master").Effects.addProperty("ADBE Ramp");
  25. // Copy layer with Property Links
  26. app.executeCommand(10310);
  27. // Paste layer
  28. app.executeCommand(20);
  29. // Rename
  30. myComp.layer("DOF_Master 2").name = "DOF_Slave";
  31. //Pre Compose Slave, hide and move to bottom of layers
  32. slaveIndexA = myComp.layer("DOF_Slave").index
  33. myComp.layers.precompose([slaveIndexA],"DOF_Slave Comp","True");
  34. myComp.selectedLayers[0].enabled = false;
  35. myComp.selectedLayers[0].moveToEnd();
  36. slaveIndex = myComp.layer("DOF_Slave Comp").index
  37. //add Camera Blur, set effect properties to Master Layer and make adjustment layer
  38. myComp.layer("DOF_Master").effect("Gradient Ramp").enabled = false
  39. myComp.layer("DOF_Master").Effects.addProperty("ADBE Camera Lens Blur");
  40. myComp.layer("DOF_Master").effect("Camera Lens Blur").property("Layer").setValue(slaveIndex);
  41. myComp.layer("DOF_Master").effect("Camera Lens Blur").property("Invert Blur Map").setValue(true);
  42. myComp.layer("DOF_Master").adjustmentLayer = true
  43. myComp.layer("DOF_Master").selected = true
  44. myComp.layer("DOF_Slave Comp").selected = false
  45. }
  46. createDOF();
  47. app.endUndoGroup();

Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>