Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script mysteriously crashing, can’t figure out why

  • Script mysteriously crashing, can’t figure out why

    Posted by Patrick Batterson on October 31, 2023 at 2:05 pm

    Hey guys,
    This script I’ve been working crashes and I’m running out of ideas as to why.
    It runs fine on my windows computer but on my mac, whenever I check the “Suffix” checkbox and click inside the Suffix text box After Effects crashes. All other checkboxes and text inputs work fine and behaves as expected. I’ve removed a lot of code to only present the problematic part, if any of you have any idea of why this is happening, I’d be super grateful.

    var panelGlobal = this;

    var scriptUIPanel = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette");

    if (!(panelGlobal instanceof Panel)) scriptUIPanel.text = "PerfectCompNamer";

    var prefixInput, clientInput, projectInput, placementInput, dimensionsWidth, dimensionsHeight, lengthInput, languageInput, suffixInput;

    var prefixCheckbox, clientCheckbox, projectCheckbox, placementCheckbox, dimensionsCheckbox, lengthCheckbox, languageCheckbox, suffixCheckbox;

    function enableDisableEdittext(checkbox, edittext) {

    edittext.enabled = checkbox.value;

    }

    // SCRIPTUIPANEL

    // =============

    scriptUIPanel.orientation = "column";

    scriptUIPanel.alignChildren = ["center","top"];

    scriptUIPanel.spacing = 10;

    scriptUIPanel.margins = 16;

    // NAMINGPROPERTIES

    // ================

    var namingProperties = scriptUIPanel.add("panel", undefined, undefined, {name: "namingProperties"});

    namingProperties.text = "Naming Properties";

    namingProperties.orientation = "column";

    namingProperties.alignChildren = ["left","top"];

    namingProperties.spacing = 10;

    namingProperties.margins = 10;

    // CLIENTGROUP

    // ===========

    var clientGroup = namingProperties.add("group", undefined, {name: "clientGroup"});

    clientGroup.orientation = "row";

    clientGroup.alignChildren = ["left","center"];

    clientGroup.spacing = 10;

    clientGroup.margins = 0;

    var clientCheckbox = clientGroup.add("checkbox", undefined, undefined, {name: "clientCheckbox"});

    // CLIENTWRAPPER

    // =============

    var clientWrapper = clientGroup.add("group", undefined, {name: "clientWrapper"});

    clientWrapper.preferredSize.width = 80;

    clientWrapper.orientation = "row";

    clientWrapper.alignChildren = ["left","center"];

    clientWrapper.spacing = 10;

    clientWrapper.margins = 0;

    var clientPropertyText = clientWrapper.add("statictext", undefined, undefined, {name: "clientPropertyText"});

    clientPropertyText.text = "Client:";

    // CLIENTGROUP

    // ===========

    var clientInput = clientGroup.add('edittext {properties: {name: "clientInput"}}');

    clientInput.preferredSize.width = 120;

    enableDisableEdittext(clientCheckbox, clientInput);

    // PROJECTGROUP

    // ============

    var projectGroup = namingProperties.add("group", undefined, {name: "projectGroup"});

    projectGroup.orientation = "row";

    projectGroup.alignChildren = ["left","center"];

    projectGroup.spacing = 10;

    projectGroup.margins = 0;

    var projectCheckbox = projectGroup.add("checkbox", undefined, undefined, {name: "projectCheckbox"});

    // PROJECTWRAPPER

    // ==============

    var projectWrapper = projectGroup.add("group", undefined, {name: "projectWrapper"});

    projectWrapper.preferredSize.width = 80;

    projectWrapper.orientation = "row";

    projectWrapper.alignChildren = ["left","center"];

    projectWrapper.spacing = 10;

    projectWrapper.margins = 0;

    var projectPropertyText = projectWrapper.add("statictext", undefined, undefined, {name: "projectPropertyText"});

    projectPropertyText.text = "Project:";

    // PROJECTGROUP

    // ============

    var projectInput = projectGroup.add('edittext {properties: {name: "projectInput"}}');

    projectInput.preferredSize.width = 120;

    enableDisableEdittext(projectCheckbox, projectInput);

    // PLACEMENTGROUP

    // ==============

    var placementGroup = namingProperties.add("group", undefined, {name: "placementGroup"});

    placementGroup.orientation = "row";

    placementGroup.alignChildren = ["left","center"];

    placementGroup.spacing = 10;

    placementGroup.margins = 0;

    var placementCheckbox = placementGroup.add("checkbox", undefined, undefined, {name: "placementCheckbox"});

    // PLACEMENTWRAPPER

    // ================

    var placementWrapper = placementGroup.add("group", undefined, {name: "placementWrapper"});

    placementWrapper.preferredSize.width = 80;

    placementWrapper.orientation = "row";

    placementWrapper.alignChildren = ["left","center"];

    placementWrapper.spacing = 10;

    placementWrapper.margins = 0;

    var placementPropertyText = placementWrapper.add("statictext", undefined, undefined, {name: "placementPropertyText"});

    placementPropertyText.text = "Placement:";

    // PLACEMENTGROUP

    // ==============

    var placementInput = placementGroup.add('edittext {properties: {name: "placementInput"}}');

    placementInput.preferredSize.width = 120;

    enableDisableEdittext(placementCheckbox, placementInput);

    // DIMENSIONSGROUP

    // ================

    var dimensionsGroup = namingProperties.add("group", undefined, {name: "dimensionsGroup"});

    dimensionsGroup.orientation = "row";

    dimensionsGroup.alignChildren = ["left","center"];

    dimensionsGroup.spacing = 10;

    dimensionsGroup.margins = 0;

    var dimensionsCheckbox = dimensionsGroup.add("checkbox", undefined, undefined, {name: "dimensionsCheckbox"});

    // dimensionsWRAPPER

    // ==================

    var dimensionsWrapper = dimensionsGroup.add("group", undefined, {name: "dimensionsWrapper"});

    dimensionsWrapper.preferredSize.width = 80;

    dimensionsWrapper.orientation = "row";

    dimensionsWrapper.alignChildren = ["left","center"];

    dimensionsWrapper.spacing = 10;

    dimensionsWrapper.margins = 0;

    var dimensionsPropertyText = dimensionsWrapper.add("statictext", undefined, undefined, {name: "dimensionsPropertyText"});

    dimensionsPropertyText.text = "Dimensions:";

    // dimensionsGROUP

    // ================

    var dimensionsWidthInput = dimensionsGroup.add('edittext {properties: {name: "dimensionsWidthInput"}}');

    dimensionsWidthInput.preferredSize.width = 45;

    enableDisableEdittext(dimensionsCheckbox, dimensionsWidthInput);

    var dimensionsDivider = dimensionsGroup.add("statictext", undefined, undefined, {name: "dimensionsDivider"});

    dimensionsDivider.text = "x";

    var dimensionsHeightInput = dimensionsGroup.add('edittext {properties: {name: "dimensionsHeightInput"}}');

    dimensionsHeightInput.preferredSize.width = 45;

    enableDisableEdittext(dimensionsCheckbox, dimensionsHeightInput);

    // LENGTHGROUP

    // ===========

    var lengthGroup = namingProperties.add("group", undefined, {name: "lengthGroup"});

    lengthGroup.orientation = "row";

    lengthGroup.alignChildren = ["left","center"];

    lengthGroup.spacing = 10;

    lengthGroup.margins = 0;

    var lengthCheckbox = lengthGroup.add("checkbox", undefined, undefined, {name: "lengthCheckbox"});

    // LENGTHWRAPPER

    // =============

    var lengthWrapper = lengthGroup.add("group", undefined, {name: "lengthWrapper"});

    lengthWrapper.preferredSize.width = 80;

    lengthWrapper.orientation = "row";

    lengthWrapper.alignChildren = ["left","center"];

    lengthWrapper.spacing = 10;

    lengthWrapper.margins = 0;

    var lengthPropertyText = lengthWrapper.add("statictext", undefined, undefined, {name: "lengthPropertyText"});

    lengthPropertyText.text = "Length:";

    // LENGTHGROUP

    // ===========

    var lengthInput = lengthGroup.add('edittext {properties: {name: "lengthInput"}}');

    //lengthInput.text = lastInputs.length;

    lengthInput.preferredSize.width = 120;

    enableDisableEdittext(lengthCheckbox, lengthInput);

    // LANGUAGEGROUP

    // =============

    var languageGroup = namingProperties.add("group", undefined, {name: "languageGroup"});

    languageGroup.orientation = "row";

    languageGroup.alignChildren = ["left","center"];

    languageGroup.spacing = 10;

    languageGroup.margins = 0;

    var languageCheckbox = languageGroup.add("checkbox", undefined, undefined, {name: "languageCheckbox"});

    // LANGUAGEWRAPPER

    // ===============

    var languageWrapper = languageGroup.add("group", undefined, {name: "languageWrapper"});

    languageWrapper.preferredSize.width = 80;

    languageWrapper.orientation = "row";

    languageWrapper.alignChildren = ["left","center"];

    languageWrapper.spacing = 10;

    languageWrapper.margins = 0;

    var languagePropertyText = languageWrapper.add("statictext", undefined, undefined, {name: "languagePropertyText"});

    languagePropertyText.text = "Language:";

    // LANGUAGEGROUP

    // =============

    var languageInput = languageGroup.add('edittext {properties: {name: "languageInput"}}');

    languageInput.preferredSize.width = 120;

    enableDisableEdittext(languageCheckbox, languageInput);

    // additionalProperties

    // ================

    var additionalProperties = scriptUIPanel.add("panel", undefined, undefined, {name: "additionalProperties"});

    additionalProperties.text = "Additional Properties";

    additionalProperties.orientation = "column";

    additionalProperties.alignChildren = ["left","top"];

    additionalProperties.spacing = 10;

    additionalProperties.margins = 10;

    // prefixGROUP

    // ===========

    var prefixGroup = additionalProperties.add("group", undefined, {name: "prefixGroup"});

    prefixGroup.orientation = "row";

    prefixGroup.alignChildren = ["left","center"];

    prefixGroup.spacing = 10;

    prefixGroup.margins = 0;

    var prefixCheckbox = prefixGroup.add("checkbox", undefined, undefined, {name: "prefixCheckbox"});

    // prefixWrapper

    // ======

    var prefixWrapper = prefixGroup.add("group", undefined, {name: "prefixWrapper"});

    prefixWrapper.preferredSize.width = 80;

    prefixWrapper.orientation = "row";

    prefixWrapper.alignChildren = ["left","center"];

    prefixWrapper.spacing = 10;

    prefixWrapper.margins = 0;

    var prefixPropertyText = prefixWrapper.add("statictext", undefined, undefined, {name: "prefixWrapper"});

    prefixPropertyText.text = "Prefix:";

    // prefixGROUP

    // ===========

    var prefixInput = prefixGroup.add('edittext {properties: {name: "prefixInput"}}');

    prefixInput.preferredSize.width = 120;

    enableDisableEdittext(prefixCheckbox, prefixInput);

    // suffixGROUP

    // =============

    var suffixGroup = additionalProperties.add("group", undefined, {name: "suffixGroup"});

    suffixGroup.orientation = "row";

    suffixGroup.alignChildren = ["left","center"];

    suffixGroup.spacing = 10;

    suffixGroup.margins = 0;

    var suffixCheckbox = suffixGroup.add("checkbox", undefined, undefined, {name: "suffixCheckbox"});

    // suffixWRAPPER

    // ===============

    var suffixWrapper = suffixGroup.add("group", undefined, {name: "suffixWrapper"});

    suffixWrapper.preferredSize.width = 80;

    suffixWrapper.orientation = "row";

    suffixWrapper.alignChildren = ["left","center"];

    suffixWrapper.spacing = 10;

    suffixWrapper.margins = 0;

    var suffixPropertyText = suffixWrapper.add("statictext", undefined, undefined, {name: "suffixPropertyText"});

    suffixPropertyText.text = "Suffix:";

    // suffixGROUP

    // =============

    var suffixInput = suffixGroup.add("edittext", undefined, undefined, {name: "suffixinput"});

    suffixInput.preferredSize.width = 120;

    enableDisableEdittext(suffixCheckbox, suffixInput);

    // PREVIEWPANEL

    // ============

    var previewPanel = scriptUIPanel.add("panel", undefined, undefined, {name: "previewPanel"});

    previewPanel.text = "Name Preview";

    previewPanel.preferredSize.width = 260;

    previewPanel.orientation = "column";

    previewPanel.alignChildren = ["left","top"];

    previewPanel.spacing = 10;

    previewPanel.margins = 10;

    var previewText = previewPanel.add("statictext", undefined, undefined, {name: "previewText"});

    previewText.text = "StaticText";

    previewText.preferredSize.width = 120;

    previewText.alignment = ["center","top"];

    // buttonWrapper

    // ======

    var buttonWrapper = scriptUIPanel.add("group", undefined, {name: "buttonWrapper"});

    buttonWrapper.orientation = "row";

    buttonWrapper.alignChildren = ["left","center"];

    buttonWrapper.spacing = 10;

    buttonWrapper.margins = 0;

    var applyButton = buttonWrapper.add("button", undefined, undefined, {name: "applyButton"});

    applyButton.text = "Apply Naming";

    var cancelButton = buttonWrapper.add("button", undefined, undefined, {name: "cancelButton"});

    cancelButton.text = "Cancel";

    prefixCheckbox.onClick = function() {

    enableDisableEdittext(prefixCheckbox, prefixInput);

    updatePreviewText();

    };

    clientCheckbox.onClick = function() {

    enableDisableEdittext(clientCheckbox, clientInput);

    updatePreviewText();

    };

    projectCheckbox.onClick = function() {

    enableDisableEdittext(projectCheckbox, projectInput);

    updatePreviewText();

    };

    placementCheckbox.onClick = function() {

    enableDisableEdittext(placementCheckbox, placementInput);

    updatePreviewText();

    };

    dimensionsCheckbox.onClick = function() {

    enableDisableEdittext(dimensionsCheckbox, dimensionsWidthInput);

    enableDisableEdittext(dimensionsCheckbox, dimensionsHeightInput);

    updatePreviewText();

    };

    lengthCheckbox.onClick = function() {

    enableDisableEdittext(lengthCheckbox, lengthInput);

    updatePreviewText();

    };

    languageCheckbox.onClick = function() {

    enableDisableEdittext(languageCheckbox, languageInput);

    updatePreviewText();

    };

    suffixCheckbox.onClick = function() {

    enableDisableEdittext(suffixCheckbox, suffixInput);

    updatePreviewText();

    };

    scriptUIPanel.show();

    Patrick Batterson replied 11 months, 2 weeks ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy