🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9849

Re: [AS] Breaking Threads (again)

#9849
From: Olav_Kvern
Date: Wed, 19 Jul 2006 18:21
61 lines
3426 bytes
Ralf--

The trouble, really, is finding the appropriate place to use the duplicate method (or "command," in AppleScript terms). Duplicate exists on individual page items--but if you duplicate the items separately, as you've found, the links between the frames get broken.

It's easy to work around this, though--just group the frames you want to keep together, then duplicate the group, as shown in the following example:



//DuplicateLinkedFrames.jsx 
//An InDesign CS2 JavaScript 
// 
//Shows how to duplicate linked text frames. 
main(); 
function main(){ 
	var myDocument = myCreateExampleDocument(); 
	//Group text frames A and B 
	var myTextFrameA = myDocument.pages.item(0).textFrames.item("TextFrameA"); 
	var myTextFrameB = myDocument.pages.item(0).textFrames.item("TextFrameB"); 
	var myGroup = myDocument.pages.item(0).groups.add([myTextFrameA, myTextFrameB]); 
	//Duplicate the group 
	var myNewGroup = myGroup.duplicate(); 
	//Ungroup the group 
	myGroup.ungroup(); 
	//Delete the text in text frames A and B 
	var myText = myTextFrameA.parentStory.texts.itemByRange(myTextFrameA.characters.item(0), myTextFrameB.characters.item(-1)); 
	myText.remove(); 
	//Delete text frames A and B 
	myTextFrameA.remove(); 
	myTextFrameB.remove(); 
	//Ungroup the duplicate frames (which are still linked) 
	myNewGroup.ungroup(); 
} 
function myCreateExampleDocument(){ 
	//Create an example document. 
	var myDocument = app.documents.add(); 
	//Set the measurement units to points. 
	myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points; 
	myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points; 
	myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin; 
	//Create a text frame on page 1. 
	var myTextFrameA = myDocument.pages.item(0).textFrames.add({geometricBounds:[72, 72, 144, 144]}); 
	myTextFrameA.label = "TextFrameA"; 
	//Create another text frame on page 1. 
	var myTextFrameB = myDocument.pages.item(0).textFrames.add({geometricBounds:[228, 72, 300, 144]}); 
	myTextFrameB.label = "TextFrameB"; 
	//Add a page. 
	var myNewPage = myDocument.pages.add(); 
	//Create another text frame on page 2. 
	var myTextFrameC = myDocument.pages.item(1).textFrames.add({geometricBounds:[72, 72, 144, 144]}) 
	//Link TextFrameA to TextFrameB using the nextTextFrame property. 
	myTextFrameA.nextTextFrame = myTextFrameB; 
	//Link TextFrameC to TextFrameB using the previousTextFrame property. 
	myTextFrameC.previousTextFrame = myTextFrameB; 
	//Fill the text frames with placeholder text. 
	myTextFrameA.contents = TextFrameContents.placeholderText; 
	return myDocument; 
}

Thanks,

Ole
Technical Details
Message-ID: <3bc0e432.8@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.ispa.de!news.ecp.fr!news.stben.net!webcrossing
References: <3bc0e432.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,3e8ecaf92c53dd01
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Olav_Kvern@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: [AS] Breaking Threads (again)
Message-ID: <3bc0e432.8@webcrossing.la2eafNXanI>
Date: Wed, 19 Jul 2006 11:21:40 -0700
References: <3bc0e432.-1@webcrossing.la2eafNXanI>
Lines: 72
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!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.ispa.de!news.ecp.fr!news.stben.net!webcrossing