Article View: adobe.scripting.indesign
Article #9833Re: [Mac Indesign CS2 JS] add rectangle as big as the page
From: Revier_Daniel
Date: Wed, 19 Jul 2006 10:09
Date: Wed, 19 Jul 2006 10:09
54 lines
3047 bytes
3047 bytes
I would prefer this one:
//User Dialog
with(myDialog = app.dialogs.add({name:"Add rectangle to pagesize", canCancel:true})){
myDialogColumn = dialogColumns.add()
//Defined colors of the document
docColors = new Array();
docColors[0] = "None"
for(i=0; i<app.colors.length; i++){ docColors[i+1] = app.colors[i].name; } //Defined stroke styles of the document docStrokes = new Array(); for(i=0; i<app.strokeStyles.length; i++){ docStrokes[i] = app.strokeStyles[i].name; }
with(myDialogColumn){
with(borderPanels.add()){
with(myColumn = dialogColumns.add()){
with(myRow = dialogRows.add()){
staticTexts.add({staticLabel:"fill color:"});
myFillColor = dropdowns.add({stringList: docColors, selectedIndex: 0});
}
with(myRow = dialogRows.add()){
staticTexts.add({staticLabel:"stroke color:"});
myStrokeColor = dropdowns.add({stringList: docColors, selectedIndex: 0});
}
with(myRow = dialogRows.add()){
staticTexts.add({staticLabel:"stroke style:"});
myStrokeStyle = dropdowns.add({stringList: docStrokes, selectedIndex: 0});
}
with(myRow = dialogRows.add()){
staticTexts.add({staticLabel:"stroke weight:"});
myStrokeWeight = integerEditboxes.add({editContents: "1"});
}
}
}
}
}
if(app.documents.length > 0){
//Show the dialog
myReturn = myDialog.show();
if(myReturn){
var myDoc = app.activeDocument;
var bounds = new Array(0, 0, myDoc.documentPreferences.pageHeight, myDoc.documentPreferences.pageWidth);
myDoc.pages[0].rectangles.add({geometricBounds: bounds, strokeWeight: myStrokeWeight.editContents, strokeType: app.activeDocument.strokeStyles[myStrokeStyle.selectedIndex], strokeColor: docColors[myStrokeColor.selectedIndex], fillColor: docColors[myFillColor.selectedIndex]});
myDialog.destroy();
//Add 4 Guides
myDoc.guides.add({orientation: HorizontalOrVertical.horizontal, location: 2});
myDoc.guides.add({orientation: HorizontalOrVertical.horizontal, location: myDoc.documentPreferences.pageHeight-2});
myDoc.guides.add({orientation: HorizontalOrVertical.vertical, location: 2});
myDoc.guides.add({orientation: HorizontalOrVertical.vertical, location: myDoc.documentPreferences.pageWidth -2});
}
}else{
alert("No document open!");
}
Daniel
Technical Details
Message-ID:
<3bc0f435.4@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!syros.belnet.be!news.belnet.be!news.stben.net!webcrossingReferences:
<3bc0f435.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,9f82f6293d15dcff X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Revier_Daniel@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: [Mac Indesign CS2 JS] add rectangle as big as the page Message-ID: <3bc0f435.4@webcrossing.la2eafNXanI> Date: Wed, 19 Jul 2006 03:09:36 -0700 References: <3bc0f435.-1@webcrossing.la2eafNXanI> Lines: 73 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!syros.belnet.be!news.belnet.be!news.stben.net!webcrossing