🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16953

Re: Resetting a frame to a default shape

#16953
From: Olav Kvern
Date: Tue, 08 Jul 2003 15:08
56 lines
2995 bytes
Gang--

Good one, Shane--I was just about to post an "entire path" example! I'll console myself by posting this, instead:



--ConvertToOval 
--An InDesign 2.0x script 
--Converts the selected page item (or items) to an oval  
--by rearranging its path points and direction handles. 
set myMagicConstant to 0.552284746667 
tell application "InDesign 2.0.2" 
	set myPageItems to {oval, rectangle, polygon, text frame} 
	set mySelection to selection 
	if (count mySelection) > 0 then 
		repeat with myCounter from 1 to (count mySelection) 
			if (class of item myCounter of mySelection) is in myPageItems then 
				set myPageItem to item myCounter of mySelection 
				set {myY1, myX1, myY2, myX2} to geometric bounds of myPageItem 
				set myHalfWidth to (myX2 - myX1) / 2 
				set myX3 to myX1 + myHalfWidth 
				set myXOffset to myHalfWidth * myMagicConstant 
				set myHalfHeight to (myY2 - myY1) / 2 
				set myY3 to myY1 + myHalfHeight 
				set myYOffset to myHalfHeight * myMagicConstant 
				set myPath to path 1 of myPageItem 
				set entire path of myPath to {{myX1, myY3}, {myX3, myY2}, {myX2, myY3}, {myX3, myY1}} 
				set myPathPoint to path point 1 of myPath 
				set point type of myPathPoint to smooth 
				set left direction of myPathPoint to {myX1, myY3 - myYOffset} 
				set right direction of myPathPoint to {myX1, myY3 + myYOffset} 
				set myPathPoint to path point 2 of myPath 
				set point type of myPathPoint to smooth 
				set left direction of myPathPoint to {myX3 - myXOffset, myY2} 
				set right direction of myPathPoint to {myX3 + myXOffset, myY2} 
				set myPathPoint to path point 3 of myPath 
				set point type of myPathPoint to smooth 
				set left direction of myPathPoint to {myX2, myY3 + myYOffset} 
				set right direction of myPathPoint to {myX2, myY3 - myYOffset} 
				set myPathPoint to path point 4 of myPath 
				set point type of myPathPoint to smooth 
				set left direction of myPathPoint to {myX3 + myXOffset, myY1} 
				set right direction of myPathPoint to {myX3 - myXOffset, myY1} 
			end if 
		end repeat 
	end if 
end tell 




Note that "entire path" doesn't deal with the curve handles (left and right direction), so we still have to set those individually.

Thanks,

Ole
Technical Details
Message-ID: <1de9c5ff.5@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de9c5ff.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,cd54cee4fda94831
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-07-08 08:38:06 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Resetting a frame to a default shape
Message-ID: <1de9c5ff.5@WebX.la2eafNXanI>
Date: Tue, 8 Jul 2003 08:08:50 -0700
References: <1de9c5ff.-1@WebX.la2eafNXanI>
Lines: 55
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit