Variable becomes invalid during loop (CS6 based)

Advertisement
November 30

First off I know that CC fixed this, but unfortunately my hands are tied and I have to use CS6 for this process. The script below is built to allow user to select precomp layers within a master comp. It then strips each precomp down to just itself and then the project is reduced to just the master comp and associated assets. It's actually inspired by Jeff Almasol's script he made for me years ago. I've just customized my own variation due to an issue in CS6 with the Reduce Project function. The issue arrising is that the loop goes off and processes the first selected precomp properly, but the master comp variable becomes invalid upon the second precomp processed. The script involves saving the project file and reopening the main source project during the loop process. Any thoughts as to why the variable is becoming invalid? The lines marked BOLD and ITALIC are the trouble spots.
     function compToProjectsScript(thisObj){
          try{
               var masterComp, curItem, selLayerIndices, selLayerIndicesLength, curLayer, curLayerName, saveFolder, newFileInfo, curLayerIndex, folderString, allItems;
               ///FUNCTIONS
               //retrieveSelectedLayersIndex
               function retrieveSelectedLayersIndex(compObj){
                    var selLayers, selLayersLength, layerIndex;
                    layerIndex = new Array();
                    selLayers = compObj.selectedLayers;
                    selLayersLength = selLayers.length;
                    for(var l=0; l<selLayersLength; l++){
                         if(selLayers[l].source instanceof CompItem){
                              layerIndex.push(selLayers[l].index);
                    return layerIndex;
               //reduceCompToLayer
               function reduceCompToLayer(layerObj, compObj){
                    var layerCount = compObj.numLayers;
                    var lastLayer = compObj.layer(layerCount);
                    layerObj.moveBefore(lastLayer);
                    for(var i=1; i<=layerCount-2; i++){
                         firstLayerLocked = compObj.layer(1).locked;
                         if(firstLayerLocked == true){
                              firstLayerLocked = false;
                              compObj.layer(1).remove();
                         }else{
                              compObj.layer(1).remove();
               //retrieveParentCompIndexNum
               function retrieveParentCompIndexNum(){
                    var proj, openedComp, parentComp, itemcount;
                    proj = app.project;
                    openedComp = proj.activeItem;
                    itemcount = proj.numItems;
                    if(openedComp instanceof CompItem){
                         parentComp = {'name': openedComp.name, 'id': openedComp.id};
                         for(var i=1; i<=itemcount; i++){
                              if(proj.item(i).name == parentComp.name && proj.item(i).id == parentComp.id){
                                   return i;
              masterComp = app.project.item(retrieveParentCompIndexNum());     //VARIABLE SET
               selLayerIndices = retrieveSelectedLayersIndex(masterComp);
               selLayerIndicesLength = selLayerIndices.length;
               var curProjFile = app.project.file;
               if(curProjFile != null){
                    saveFolder = Folder.selectDialog("Choose a \"save to\" folder.");
                    if(saveFolder != null){
                         folderString = Folder.decode(saveFolder).toString();
                         app.project.save(new File(folderString + "/_Duplicate_" + curProjFile.name));
                         var dupFile = app.project.file;
                         app.beginUndoGroup("compToProject");
                              for(var i=0; i<selLayerIndicesLength; i++){
                                        app.beginSuppressDialogs();
                                             curLayerIndex = selLayerIndices[i];
                                             curLayer = masterComp.layer(curLayerIndex);     //BECOMES INVALID ON SECOND PASS
                                             curLayerName = curLayer.name;
                                             reduceCompToLayer(curLayer, masterComp);
                                             app.project.reduceProject(masterComp);
                                             newFileInfo = folderString + "/" + curLayerName + ".aep";
                                             app.project.save(new File(newFileInfo));
                                        app.endSuppressDialogs(true);
                                   app.open(curProjFile);
                         app.endUndoGroup();
                         writeLn("All done.");
               }else{
                    alert("Save project first, then try again.");
          }catch(err){alert("Error at line #" + err.line.toString() + "\r" + err.toString());}
     compToProjectsScript(this);

Advertisement

Replay

Here's that final setup I went with:
//START
     function compToProjectsScript(thisObj){
          try{
               var masterComp, curItem, selLayerIndices, selLayerIndicesLength, curLayer, curLayerName, saveFolder, newFileInfo, curLayerIndex, folderString, allItems;
               ///FUNCTIONS
               //retrieveSelectedLayersIndex
               function retrieveSelectedLayersIndex(compObj){
                    var selLayers, selLayersLength, layerIndex;
                    layerIndex = new Array();
                    selLayers = compObj.selectedLayers;
                    selLayersLength = selLayers.length;
                    for(var l=0; l<selLayersLength; l++){
                         if(selLayers[l].source instanceof CompItem){
                              layerIndex.push(selLayers[l].index);
                    return layerIndex;
               //reduceCompToLayer
               function reduceCompToLayer(layerObj, compObj){
                    var layerCount = compObj.numLayers;
                    var lastLayer = compObj.layer(layerCount);
                    layerObj.moveBefore(lastLayer);
                    for(var i=1; i<=layerCount-2; i++){
                         firstLayerLocked = compObj.layer(1).locked;
                         if(firstLayerLocked == true){
                              compObj.layer(1).locked = false;
                              compObj.layer(1).remove();
                         }else{
                              compObj.layer(1).remove();
               //retrieveParentCompIndexNum
               function retrieveParentCompIndexNum(){
                    var proj, openedComp, parentComp, itemcount;
                    proj = app.project;
                    openedComp = proj.activeItem;
                    itemcount = proj.numItems;
                    if(openedComp instanceof CompItem){
                         parentComp = {'name': openedComp.name, 'id': openedComp.id};
                         for(var i=1; i<=itemcount; i++){
                              if(proj.item(i).name == parentComp.name && proj.item(i).id == parentComp.id){
                                   return i;
               compIndex = retrieveParentCompIndexNum();
               masterComp = app.project.item(compIndex);
               selLayerIndices = retrieveSelectedLayersIndex(masterComp);
               selLayerIndicesLength = selLayerIndices.length;
               var curProjFile = app.project.file;
               if(curProjFile != null){
                    saveFolder = Folder.selectDialog("Choose a \"save to\" folder.");
                    if(saveFolder != null){
                         folderString = Folder.decode(saveFolder).toString();
                         app.project.save(new File(folderString + "/_Duplicate_" + curProjFile.name));
                         var dupFile = app.project.file;
                         app.beginUndoGroup("compToProject");
                              for(var i=0; i<selLayerIndicesLength; i++){
                                        app.beginSuppressDialogs();
                                             sourceComp = app.project.activeItem;
                                             curLayerIndex = selLayerIndices[i];
                                             curLayer = sourceComp.layer(curLayerIndex);
                                             curLayerName = curLayer.name;
                                             reduceCompToLayer(curLayer, sourceComp);
                                             app.project.reduceProject(sourceComp);
                                             newFileInfo = folderString + "/" + curLayerName + ".aep";
                                             app.project.save(new File(newFileInfo));
                                        app.endSuppressDialogs(true);
                                   app.open(dupFile);
                         app.endUndoGroup();
                         writeLn("All done.");
               }else{
                    alert("Save project first, then try again.");
          }catch(err){alert("Error at line #" + err.line.toString() + "\r" + err.toString());}
     compToProjectsScript(this);
//END

View 5 Replies

When do VI and queue references become invalid?

October 11

Hi all, I have a fairly complicated problem, so please bear with me. 1)  I have a reentrant SubVI (let's call it VI "Assign") that has an input cluster of (VI ref, queue ref) (let's call the cluster type "Refs").  If the VI ref is inva

View All Replies

MATERIALIZED VIEW BECOMES INVALID AFTER REFRESH

November 30

Hello All, I have wierd problem , In my enviroinment we have a MATERIALIZED VIEW ,which is refreshed by a sheduled DBMS_SNAPSHOT.REFRESH Job post the refresh it becomes invalid and every time we have to compile it manually ,Could anybody help with a

View All Replies

Problem of Materialized view become invalid

November 30

Hi, I know that because of DML or DDL operation My Materialized view invalid. But I want to know the from which table it become invalid. Is there any dictionary view from which I can find ?Hi, I know that because of DML or DDL operation My Materializ

View All Replies

Why would a vi that deals with xl become broken during an executable build?

November 30

Why would a vi that deals with excel spreadsheet become broken during an executable build?  Excel vi's fine in soft copy.  But during executable build the vi's dealing with opening an excel spredsheet (open specific workbook and set cell value) becom

View All Replies

Valid Serial number called invalid during installation.

November 30

After a fresh load on my computer, I uninstalled and was reinstalling my boxed Pre. Elements 8, when I got a message that the SN was invalid during the installation. The serial number entered is printed on the box, and was previously working.  I woul

View All Replies

Nano becomes hot during a short time charging from PC. Is it abnormal?

November 30

Hi, thanks to help My nano 5th generation 8G, purchase from Apple becomes hot during a short time charging from PC. Is it abnormal? The wire/connector is not hot and it's the one include in the box.SteveDC wrote: I setup my MacBook Pro and did not ru

View All Replies

How do I set a variable within a 'for' loop grid array

October 11

I'm afraid I'm stuck again! The next stage in the animation that I'm working on,  is to set up a boolean, 'drilled = false', so that all instances of the attachMovie ('openCircle') have a boolean 'drilled = false' associated with them. Then when some

View All Replies

Dynamic xfa form - digital signature becomes invalid

November 30

Greetings forum, I have question regarding dynamic xfa forms and hope, that you can help me. I filled a pdf form based on a dynamic xfa form (with extended rights for Reader user) using iText. When the content of the PDF is changed, the digital signa

View All Replies

Document certification becoming INVALID after Ctrl+F in Acrobat 9.  Possible bug?

October 11

Hi Am using document certifcation to protect my application Pdfs.  Have came across an issue where in the document certification is getting invalid.  AM also able to reproduce the error by working with pdfs outside my application. Below are the steps

View All Replies

Solution: Server 3.2.1 "Invalid Profile" w/ Supervision-based Enrollment

November 30

After installing Server 3.2.1, I had been fighting an "Invalid Profile" error on Apple Configurator-supervised devices trying to auto-enroll with Profile Manager. Manual enrollment continued to work as expected. This morning, I found this gem in

View All Replies

Support for Shared Variables in Third Party XP embedded based TPC's?

November 30

I have deployed an application in an XP embedded based Touch Panel (Third party). The application is working fine, but the shared variables hosted on an RT (sbRIO Board) are not getting updated in the application on TPC 1. The TPC is part of the proj

View All Replies

Cfset variable as a list loop value

November 30

I'm trying to use a list loop to create 30 numbers then set that list with cfset. Instead of typing <cfset Questions = 1,2,3,4...etc.> I'd like to make a list loop generate the 30 numbers. I just can't figure out how to set these 30 numbers as a val

View All Replies

Package with sdo_geometry has become invalid

November 30

I'm confused... I verified this package is the same as it was a month ago.. but now it is invalid and will not recompile.. no database upgrades/patches have happened. database is 11.2.0.2 patch level 12 error is PLS-00905 Object sdo_geometry is inval

View All Replies

To break during looping statement

November 30

I have customer master table. Passing the customer from "form" to "Report" for printing Outstanding Invoice Statement. my code at form : LOOP call report with parameter customer number; next customer number; END LOOP; note: customer nu

View All Replies

Reg. Tax code  in procedure TAXINJ is invalid during Billing release in VF0

November 30

dear friends when I release the billing in VF02  I am getting the bellow error ""   Tax code  in procedure TAXINJ is invalid Message no. FICORE704 Diagnosis The tax code entered is not defined in the country for this company code. System Respons

View All Replies

Invalid Serial Number - CS6 Master Suite

November 30

Anyone else having this issue? I believe Windows 8 updating to 8.1 may have something to do with it...No not all went in trial mode. Bridge no notification but for example Indesign yes trial mode also. With checking this I now see that Photoshop is n

View All Replies

References are becoming invalid when passed to an actor using the Actor Framework

October 11

I have having an issue with passing a couple of references to an actor using the actor framework 3.0.7 (LabVIEW 2011 & TestStand 2010 SP1).  Some background: My application has three main components: Main VI -- is not part of any class and Launches U

View All Replies

Problem with variable in a for loop in a Chessboard project.

October 11

Hi, im having trouble with a chessboard project. I am trying to get the chessboard to be able to increase and decrease in size when the user enters a number. But it seems as if the program is freezing. Here is my code import java.awt.*; import java.a

View All Replies

How detect if CFMessagePort becomes invalid?

November 30

I have two processes that communicate via a CFMessagePort. Process A owns the port (created with the normal CFMessagePortCreateLocal() ), and B sends data to A via the normal CFMessagePortCreateRemote() and CFMessagePortSendRequest() calls. The commu

View All Replies

Tags:

  1. FcffairBigDataResource
  2. hp omni 10 touch bloccato
  3. iphoto 8.1.2 hanging delete plist
  4. how to fix error recovery my27
  5. screen exist used in ml81n
  6. mp01 mpn
  7. hold invoice bapi
  8. change a miro document on hold
  9. H8N4
  10. 3QVY
Copyrights 2018 Fcffair BigData Resource, All rights reserved