Skip to main content
Inspiring
August 5, 2020
Answered

How can i merge these scripts?

  • August 5, 2020
  • 1 reply
  • 1080 views

How can i merge these scripts? what i'm trying to do is make a layer named (dieline) and a Text frame named (Dieline) i want the text frame to be but in the Dieline layer. i can do each one separate minus the moving from one layer to another. but I would like it if i could have it all in one script.

function addDLf(doc, layer, name){      
            var mynBlendingSettings = { blendMode : BlendMode.OVERLAY };            
            var mynTransparencySettings = { blendingSettings : mynBlendingSettings };   
            var tfn = doc.textFrames.itemByName(name);      
            if(tfn && tfn.isValid) {            
                tfn.exit ();      
        }      
            var orignUnit = app.scriptPreferences.measurementUnit;           
            app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;    
            tfn = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {name: name, fillColor :"Dieline", fillTint: 40, transparencySettings : mynTransparencySettings});  
            tfn.geometricBounds = [doc.pages[0].bounds[2] + 0,0, doc.pages[0].bounds[2] + 0,0]  
            app.scriptPreferences.measurementUnit = orignUnit;          
            return tfn;  
            
        }   
    function doDLm(event){       
            
            var doc = event.target;     
            if(!(doc && doc.constructor.name == "Document")) {  
                return;  
        }  
            
            var myLayern = addLayer(doc, "Dieline");  
            var tfn = addTextFramen(doc, myLayern, "Dieline"); 
        } 

 

var doc = app.documents[0];
var page = doc.pages[0];

page.textFrames.add 
(
	{
		
        geometricBounds : page.bounds ,


		fillColor : "None" ,
		strokeColor : "Diecut" , 
		strokeWeight : "1pt" ,
		strokeAlignment : StrokeAlignment.CENTER_ALIGNMENT , 
        overprintStroke : true,
        
        	
		topLeftCornerRadius : "3.175mm", 
        topLeftCornerOption : CornerOptions.ROUNDED_CORNER, 
        bottomLeftCornerRadius : "3.175mm", 
        bottomLeftCornerOption : CornerOptions.ROUNDED_CORNER,
        topRightCornerRadius : "3.175mm", 
        topRightCornerOption : CornerOptions.ROUNDED_CORNER,
        bottomRightCornerRadius : "3.175mm", 
        bottomRightCornerOption : CornerOptions.ROUNDED_CORNER,
		
  

        
	}
 );   
This topic has been closed for replies.
Correct answer brian_p_dts

There is some conflicting properties in the two scripts. Using the props of the first script, a simple illustration of the task you asked is: 

 

 

 

 

 

var doc = app.documents[0];
var dieStr = "Dieline";
var mynBlendingSettings = { blendMode : BlendMode.OVERLAY };            
var mynTransparencySettings = { blendingSettings : mynBlendingSettings }
var dieLayer = doc.layers.add();
dieLayer.name = dieStr;
tfn = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {
    name: "dieline", 
    fillTint: 40, 
    transparencySettings: mynTransparencySettings, 
    fillColor : "None" ,
    strokeColor : "Diecut" , 
    strokeWeight : "1pt" ,
    strokeAlignment : StrokeAlignment.CENTER_ALIGNMENT , 
    overprintStroke : true,
    topLeftCornerRadius : "3.175mm", 
    topLeftCornerOption : CornerOptions.ROUNDED_CORNER, 
    bottomLeftCornerRadius : "3.175mm", 
    bottomLeftCornerOption : CornerOptions.ROUNDED_CORNER,
    topRightCornerRadius : "3.175mm", 
    topRightCornerOption : CornerOptions.ROUNDED_CORNER,
    bottomRightCornerRadius : "3.175mm", 
    bottomRightCornerOption : CornerOptions.ROUNDED_CORNER,
    geometricBounds : doc.pages[0].bounds
});  

 

 

 

 

 

Not sure if you need the event handler too, in the first script. 

1 reply

cbishop01Author
Inspiring
August 5, 2020

if theres a better way to do it than those 2 scripts i'm up for that as well. thanks in advance.

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
August 5, 2020

There is some conflicting properties in the two scripts. Using the props of the first script, a simple illustration of the task you asked is: 

 

 

 

 

 

var doc = app.documents[0];
var dieStr = "Dieline";
var mynBlendingSettings = { blendMode : BlendMode.OVERLAY };            
var mynTransparencySettings = { blendingSettings : mynBlendingSettings }
var dieLayer = doc.layers.add();
dieLayer.name = dieStr;
tfn = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {
    name: "dieline", 
    fillTint: 40, 
    transparencySettings: mynTransparencySettings, 
    fillColor : "None" ,
    strokeColor : "Diecut" , 
    strokeWeight : "1pt" ,
    strokeAlignment : StrokeAlignment.CENTER_ALIGNMENT , 
    overprintStroke : true,
    topLeftCornerRadius : "3.175mm", 
    topLeftCornerOption : CornerOptions.ROUNDED_CORNER, 
    bottomLeftCornerRadius : "3.175mm", 
    bottomLeftCornerOption : CornerOptions.ROUNDED_CORNER,
    topRightCornerRadius : "3.175mm", 
    topRightCornerOption : CornerOptions.ROUNDED_CORNER,
    bottomRightCornerRadius : "3.175mm", 
    bottomRightCornerOption : CornerOptions.ROUNDED_CORNER,
    geometricBounds : doc.pages[0].bounds
});  

 

 

 

 

 

Not sure if you need the event handler too, in the first script. 

cbishop01Author
Inspiring
August 5, 2020

Thank you much i'll give it a try.