🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2217

Re: [JS CS3] Releasing Anchored Objects

#2217
From: Skempy
Date: Tue, 06 Jan 2009 17:01
45 lines
2161 bytes
Harbs

Many thanks for all your help.
Your array of anchored frames technique did the trick.
And I have learnt a few new things on the way.

The working script now looks like this...

var myTextFrame = app.documents[0].textFrames.item("myTarget");
var myParagraphs = myTextFrame.paragraphs
var myWidth = (myTextFrame.geometricBounds[3]-myTextFrame.geometricBounds[1])/2
var myAOs = new Array();

for (var i = 0; i <= myParagraphs.length-1; i++) {

	var nLines = myParagraphs.item(i).lines.length;
	var myHeight = nLines*myParagraphs[i].leading*.353
	var myAnchoredFrame = myTextFrame.paragraphs.item(i).insertionPoints.item(0).textFrames.add();
	myAnchoredFrame.geometricBounds = [0, 0, myHeight, myWidth];
	with(myAnchoredFrame.anchoredObjectSettings){
	anchoredPosition = AnchorPosition.anchored;
	anchorPoint = AnchorPoint.topLeftAnchor;
	horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
	horizontalAlignment = HorizontalAlignment.leftAlign;
	verticalReferencePoint = VerticallyRelativeTo.capheight;
	verticalAlignment = VerticalAlignment.topAlign;
	if (i%2 == 0)
	{
	anchorXoffset = 0
	}
	else
	{
	anchorXoffset = -myWidth
	}
	anchorYoffset = -1
	pinPosition = false
	myAOs[i] = myAnchoredFrame
	}
	} // Loop through paragraphs

for (var j = 0; j <=myAOs.length-1;j++){ 		myAOs[j].anchoredObjectSettings.releaseAnchoredObject () 		myAOs[j].sendToBack(); 		myAOs[j].fillColor = "Gradient"; 		myAOs[j].gradientFillAngle = 90; 		}

Thanks again

Simon.
Technical Details
Message-ID: <59b7683a.10@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!webcrossing
References: <59b7683a.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,f8aa02f04e7a8179
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Skempy@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [JS CS3] Releasing Anchored Objects
Message-ID: <59b7683a.10@webcrossing.la2eafNXanI>
Date: Tue, 6 Jan 2009 09:01:24 -0800
References: <59b7683a.-1@webcrossing.la2eafNXanI>
Lines: 44
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Original-Lines: 52