AE ENHANCERS

Expressions/Scripts/Presets
It is currently Wed May 22, 2013 11:29 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Accessing Paint Attributes through scripting.
PostPosted: Mon Jan 24, 2005 6:03 pm 
Offline

Joined: Mon Jan 24, 2005 4:45 pm
Posts: 2
I would like to write a script to re-order all of the brush strokes on a Paint effect by inPoint. Unfortunately, when I select brushes in the Comp, I can't seem to access a list of all the currently selected Brushes or strokeOption's (or better yet, have After Effects query all the brushes for the selected Paint Effect). Anybody have an idea as to how I could accomplish this task?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 25, 2005 3:18 am 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 646
Location: London, UK
You can't get a list of selected brush strokes because they are PropertyGroup's not Properties, so 'selectedProperties' won't work. But you can create a loop that goes through all the strokes and checks whether they are selected.

Here's a script that finds a Paint effect on the first of any selected layers, then reports whether it is selected, how many strokes there are and whether any of them are selected. Unfortunately I appear to have hit a dead end when I try to query the stroke inPoints, presumably because that is a layer attribute, and brush strokes aren't layers. I'll do some more research on this and get back to you.

Paul T

Code:
{
   activeItem = app.project.activeItem;
   theLayer = activeItem.selectedLayers[0];

   // loop through all effects on selected layer
   for (a=1; a <= theLayer.Effects.numProperties; ++a){
      theEffect = theLayer.Effects.property(a);

      if (theEffect.name = "Paint") {

         alert(theLayer.name + " has a Paint effect.")
         if (theEffect.selected) { alert(theLayer.name + "'s Paint effect is selected"); }
         theStrokes = theEffect.property(2)
         alert("The Paint effect has " + theStrokes.numProperties + " brush strokes");

         // loop through all strokes on Paint effect
         for (b = 1; b <= theStrokes.numProperties; ++b) {
            thisStroke = theStrokes.property(b);
            if (thisStroke.selected) { alert(theStrokes.property(b).name + " is selected"); }
         }

         keepSorting = true;
         while(keepSorting) {
            keepSorting = false;
            for (b = 1; b < theStrokes.numProperties; ++b) {
               alert(theStrokes.property(b).inPoint + " " + theStrokes.property(b+1).inPoint);
               if (theStrokes.property(b).inPoint > theStrokes.property(b+1).inPoint) {
                  theStrokes.property(b+1).moveTo(b);
                  keepSorting = true;
               }
            }
         }
      }
   }
}


Last edited by Paul Tuersley on Sun Mar 13, 2005 2:56 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 25, 2005 3:30 am 
Offline

Joined: Mon Jan 24, 2005 4:45 pm
Posts: 2
Paul Tuersley wrote:
Unfortunately I appear to have hit a dead end when I try to query the stroke inPoints, presumably because that is a layer attribute, and brush strokes aren't layers. I'll do some more research on this and get back to you.

Paul T


Thanks for the help Paul! I managed to access the brush stroke start times by doing the following (thanks also to Dan Ebberts):

Code:
var proj = app.project;
var activeComp = proj.activeItem;
var selectedLayers = activeComp.selectedLayers;
var myEffect = selectedLayers[0].property("ADBE Effect Parade");
var myPaintBrushes = myEffect.property("ADBE Paint").property("ADBE Paint Group");
var myBrush = myPaintBrushes.property(1);

// By querying the Duration you get an array with [starttime,duration]
var myProperty = myBrush.property("ADBE Paint Duration");

// So, here is the start time.
var myStartTime = myProperty.value[0];



I should have a script that works tonight. Thanks for the help,

Oliver.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group