Article View: adobe.scripting.indesign
Article #19248Re: Getting started in VB
From: Kim Kohen
Date: Sat, 28 Dec 2002 10:24
Date: Sat, 28 Dec 2002 10:24
81 lines
5189 bytes
5189 bytes
Ole,
I actually think the ID part might be the easy bit (although I can see a huge opportunity for egg on face after that statement:). My concerns are over things like parsing text files (I'm currently using Applescript's text item delimiters), creating temp files and creating complex dialogs.
here's an example from which I have snipped a large (replicated) section:
set myfile to (choose file of type "TEXT" with prompt "Please select a story to import") as text
set tempfolder to ((path to preferences) as text) & "Filestory:"
set olddelims to AppleScript's text item delimiters -- set the existing delimiters
set thestory to read file myfile as text
set AppleScript's text item delimiters to "<+++>"
tell application "InDesign 2.0.1"
set user interaction level to never interact
set mydoc to active document
tell mydoc
set properties of view preferences to {horizontal measurement units:millimeters, vertical measurement units:millimeters}
set mywhite to color "Paper"
try
set myYellow to color "xxYellow"
on error
set myYellow to make color with properties {name:"xxYellow", color space:cmyk, color value:{0, 0, 13, 0}}
end try
repeat with i from 1 to 1 -- is 9 in the actual script
-- name the parts as we go. this is necessary so the box names are different otherwise this would be redundant
set mytype to "" -- resets the type until we get to picture data
if i = 1 then
set tempfilepath to tempfolder & {"hed.txt"}
set theframe to myfile & "<+++>hed"
set thebounds to {4.0, -109.61, 30, 0.0} -- heading
-- large replicated chunk removed from here
end if
if text item i of thestory is "" then
return
else
set part to text item i of thestory -- selects heading text
end if
my my_write_temp(part, tempfilepath, tempfolder) -- write the temp files
if not mytype is "picture" then
if exists (text frame theframe) then
set myframe to (text frame theframe)
my mycorrection(theframe, tempfilepath, mywhite, mydoc)
else
my writeboxes(theframe, tempfilepath, mydoc, thebounds, myYellow)
end if
else
my my_place_picture(theframe, tempfilepath, mydoc, thebounds, mywhite)
end if
end repeat
end tell
end tell
A sample of the text file I would import follows:
<ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:><cs:96.00000><cf:Helvetica>Hello World<ct:><cs:><cf:><+++><ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:Regular><cs:><cs:32.00000><cf:Helvetica>hsdhhgs sdhfkmsdfjsdfhskldf sdjfklsf<ct:><cs:><clig:><cu:><cf:><+++><ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:Regular><cs:><cs:10.00000><cf:Helvetica>Can�t you tell me your name<ct:><cs:><cf:><+++><ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:Regular><cs:><cs:9.500000><cf:Times>A debate about some of the very essences of multiculturalism took place during a debate about Children�s Services needs at Bankstown Council�s meeting last week.
One Nation Councillor Lynn Abrahams told the council he supported �all of us becoming one� - which ALP councillors described as a �fascist� perspective.
Cr Lee said there was nothing wrong with children learning languages at kindergarten or pre school.<cs:><cl:><pba:><pfli:><+++><ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:Regular><cs:><cs:10.00000><cf:Helvetica>Mickaela and Emma outside the Canberra War Memorial<ct:><cs:><cf:><+++><ASCII-MAC>
<vsn:2.000000><fset:InDesign-Roman><ctable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>
<pstyle:><ct:Regular><cs:><cs:10.00000><cf:Helvetica><ct:><cs:><cf:><+++>Macintosh HD:Users:kimkohen:Pictures:trees 2.JPG<+++>Macintosh HD:Users:kimkohen:Pictures:iPhoto Library:2002:05:08:mickaela emma 2.JPG<+++>
cheers and thanks again
kim
PS - if you want to send me an email address I'd be happy to send you an example file and the full scripts so you can see what we're doing - we think it's pretty neat.
Technical Details
Message-ID:
<1de72498.3@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de72498.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,e8fe5c8c7eb997aa X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-28 02:37:38 PST From: "Kim Kohen" <kim@webguide.com.au> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Getting started in VB Message-ID: <1de72498.3@WebX.la2eafNXanI> Date: Sat, 28 Dec 2002 02:24:17 -0800 References: <1de72498.-1@WebX.la2eafNXanI> Lines: 112 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit