🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
2 messages
2 total messages Started by marcusstringer Tue, 17 Feb 2009 20:44
[AS CS3] Another MathType Baseline Shift Question
#1126
Author: marcusstringer
Date: Tue, 17 Feb 2009 20:44
62 lines
3161 bytes
Hi Guys,
I am using the below script to place MathType Equations into an InDesign File
Basically it searches for tags <<Filename.eps>> and replaces it with a inline graphic.

My question is:
Is there anyway I can get it to read the height of the InLine Graphic Box and then get it to baseline shift so it's centered height wise on the line, instead of the set amount of -10pt that is uses now?

We have to open the MathType Equations in Illustrator to change font and colour to Pantone etc, so they are save back as Illustrator EPS's

Below is the Script:

tell application "Adobe InDesign CS3"
	tell document 1
		set baselineVar to "Yes"
		set countVar to 0
		set imageCount to 0
		set docPath to file path as alias
		tell application "Finder"
			set imageFolder to folder (choose folder with prompt "Please choose the folder containing the appropriate MathType files") --"MathType" of artFolder
		end tell
		activate
		set allStories to stories
		repeat with s from 1 to count of items of allStories
			set theStory to item s of allStories
			if class of theStory is story then
				set theLim to count of words of theStory
				try
					repeat with i from 1 to theLim
						if word i of theStory contains "<<" then 							set theText to contents of word i of theStory as Unicode text 							set theOffset to (offset of "<<" in theText) 							set endOffset to (offset of ">>" in theText)
							set imageName to characters (theOffset + 2) through (endOffset - 1) of theText as string
							set imageFolderPath to ((imageFolder as string) & imageName)
							set wholeTag to characters theOffset through (endOffset + 1) of theText as string
							if baselineVar = "Yes" then
								set baseline shift of characters theOffset through (endOffset + 1) of word i of theStory to -10.2
							end if
							delete characters theOffset through (endOffset) of word i of theStory
							tell theStory
								tell word i
									tell character theOffset
										place imageFolderPath as alias
										set countVar to (countVar + 1)
									end tell
								end tell
							end tell
						end if
					end repeat
				end try
			end if
		end repeat
	end tell
	activate
	if countVar = 0 then
		display dialog "No Images were found" buttons "OK" default button 1 with icon 2
	else if countVar = 1 then
		display dialog "1 lonely Images has been placed." buttons "OK" default button 1
	else
		display dialog (countVar as string) & " Images have been placed." buttons "OK" default button 1
	end if
end tell

Thanks
Marcus
Re: [AS CS3] Another MathType Baseline Shift Question
#1135
Author: Shane_Stanley
Date: Tue, 17 Feb 2009 22:08
7 lines
1537 bytes
The place command will return a list containing a reference to the placed
image. You can then get the bounds of its parent, compare them with the
baseline, and change them accordingly.

-- 
Shane Stanley <sstanley@myriad-com.com.au>
AppleScript Pro Florida, April 2009 <http://scriptingmatters.com/aspro>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads