Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

after effect 2024에서 자신이 선택한 레이어를 바탕으로 아래 레이어에 Galmuri11 폰트를 91px의 크기로 가진 텍스트 레이어를 생성한 뒤…

  1. Assistant

    Hello! How can I assist you today?

  2. User

    after effect 2024에서 자신이 선택한 레이어를 바탕으로 아래 레이어에 Galmuri11 폰트를 91px의 크기로 가진 텍스트 레이어를 생성한 뒤 아래 레이어가 선택하고 있는 레이어에게 레이어에게 페어런트를 걸어준 뒤 선택한 레이어의 이름을 그대로 가져온 후 .확장자 문구는 뺀 값을 내용으로 작성하고, 아래 레이어의y좌표는 60.148, x좌표는 위 레이어와 동일하게 구성한 뒤 그 두개를 프리컴포지션으로 묶기까지 하는 스크립트를 작성해 줘

  3. Assistant

    After Effects에서 스크립트를 작성하여 특정 작업을 자동화하려면 ExtendScript를 사용해야 합니다. 아래는 요청하신 작업을 수행하는 ExtendScript입니다. 스크립트를 실행하기 전에 필요한 폰트(Galmuri11)가 설치되어 있어야 하며, After Effects가 해당 폰트를 인식할 수 있어야 합니다.

    1. After Effects를 실행한 후 스크립트 패널을 엽니다.
    2. 아래 스크립트를 복사하여 스크립트 패널에 붙여넣습니다.
    3. 스크립트를 실행합니다.
    {
        var proj = app.project;
        var selectedLayers = app.project.activeItem.selectedLayers;
        
        if (selectedLayers.length === 0) {
            alert("레이어를 하나 이상 선택해 주세요.");
        } else {
            app.beginUndoGroup("Create Text Layer and Precompose");
    
            for (var i = 0; i < selectedLayers.length; i++) {
                var sourceLayer = selectedLayers[i];
    
                // 텍스트 레이어 생성
                var textLayer = app.project.activeItem.layers.addText();
                var textProp = textLayer.property("Source Text");
                var textDocument = textProp.value;
    
                // 폰트 설정
                textDocument.font = "Galmuri11"; // 사용할 폰트 이름
                textDocument.fontSize = 91;
                
                // 선택한 레이어의 이름에서 확장자를 제거한 값을 텍스트로 설정
                var sourceName = sourceLayer.name;
                var nameWithoutExt = sourceName.replace(/\.[^/.]+$/, "");
                textDocument.text = nameWithoutExt;
                textProp.setValue(textDocument);
    
                // 레이어 위치 조정
                var sourcePos = sourceLayer.property("Position").value;
                textLayer.property("Position").setValue([sourcePos[0], 60.148]);
    
                // 페어런트 설정
                textLayer.setParentWithJump(sourceLayer);
    
                // 둘을 프리컴포지션으로 묶음
                var newComp = app.project.activeItem.layers.precompose([sourceLayer.index, textLayer.index], nameWithoutExt + "-PreComp", true);
            }
    
            app.endUndoGroup();
        }
    }
    

    이 스크립트는 선택한 레이어 아래에 새로운 텍스트 레이어를 생성하고, 해당 레이어에 필요한 속성(폰트, 크기, 내용)을 설정합니다. 그런 다음 텍스트 레이어를 선택된 레이어에 페어런팅합니다. 마지막으로 두 레이어를 프리컴포지션으로 묶습니다.

    스크립트를 사용하는 동안 발생할 수 있는 문제에 대비해 작업을 실시하기 전에 프로젝트를 저장하세요. 이 스크립트는 기본적인 예제이며, 필요에 따라 조정할 수 있습니다.

  4. User

    synthx error

  5. Assistant

    ExtendScript는 스크립트 실행 시 엄격한 규칙을 따릅니다. synthx 오류가 발생하는 상황에서는 구문 오류나 논리 오류일 가능성이 큽니다. 아래는 특정 구문 오류를 바로잡고, 요청하신 기능을 포함한 더욱 신뢰성 있는 스크립트를 다시 작성한 것입니다.

    아래의 스크립트를 다시 시도해 보세요:

    {
        function createTextLayerWithParent() {
            var proj = app.project;
            var comp = proj.activeItem;
    
            if (!(comp instanceof CompItem)) {
                alert("컴포지션을 활성화해 주세요.");
                return;
            }
    
            var selectedLayers = comp.selectedLayers;
    
            if (selectedLayers.length === 0) {
                alert("레이어를 하나 이상 선택해 주세요.");
                return;
            }
    
            app.beginUndoGroup("Create Text Layer and Precompose");
    
            for (var i = 0; i < selectedLayers.length; i++) {
                var sourceLayer = selectedLayers[i];
    
                // 텍스트 레이어 생성
                var textLayer = comp.layers.addText();
                var textProp = textLayer.property("Source Text");
                var textDocument = textProp.value;
    
                // 폰트 설정
                textDocument.font = "Galmuri11"; // 사용할 폰트 이름
                textDocument.fontSize = 91;
    
                // 선택한 레이어의 이름에서 확장자를 제거한 값을 텍스트로 설정
                var sourceName = sourceLayer.name;
                var nameWithoutExt = sourceName.replace(/\.[^/.]+$/, "");
                textDocument.text = nameWithoutExt;
                textProp.setValue(textDocument);
    
                // 레이어 위치 조정
                var sourcePos = sourceLayer.property("Position").value;
                textLayer.property("Position").setValue([sourcePos[0], 60.148]);
    
                // 페어런트 설정
                textLayer.setParentWithJump(sourceLayer);
    
                // 지금까지 추가된 레이어를 포함하여 프리컴포지션
                var layersToPrecompose = [textLayer.index, sourceLayer.index];
                comp.layers.precompose(layersToPrecompose, nameWithoutExt + "-PreComp", true);
            }
    
            app.endUndoGroup();
        }
    
        createTextLayerWithParent();
    }
    

    이 스크립트는 각 단계에서 선택된 컴포지션 및 레이어가 있는지 확인하고, 선택한 레이어 아래에 텍스트 레이어를 생성하며, 텍스트 레이어에 필요한 속성(폰트, 크기, 내용)을 설정합니다. 그리고 텍스트 레이어를 선택된 레이어에 페어런팅한 뒤, 두 레이어를 프리컴포지션으로 묶습니다.

    1. After Effects를 실행한 후 스크립트 패널을 엽니다.
    2. 스크립트 패널에 위 스크립트를 복사하여 붙여넣습니다.
    3. 스크립트를 실행합니다.

    이 과정에서 문제가 발생하면 에러 메시지를 확인하고, 문제 해결을 시도해 보세요. 에러 메시지는 문제를 더 명확하게 이해하는 데 도움이 됩니다.