[CS3 JS] Getting a page item by its script label
I have a text frame on a master page with its script label set. In my script, I am trying to get a reference to the text frame with this:
var doc = app.activeDocument;
var spread = doc.masterSpreads[0];
var tabFrame = spread.allPageItems.item("TabLeft");
I get the error "spread.allPageItems.item is not a function"
Any help will be appreciated. Thanks.
Rick
Hi Rick,
spread.allPageItems returns a flattened array of all of the page items in the spread, at any level of the hierarchy (i.e., inside groups and other page items). Is that what you want? Sadly, allPageItems does not benefit from the special case where we use the label as a name, so you'll have to iterate if that's what you want.
As Peter says (thanks, Peter!), spread.pageItems.item("label") gives you all of the page items whose label matches the string, but it does so in sort of a weird way--you'll always get a page item object. If no page items match, you get an invalid page item; if one matched, you get a single page item, and if multiple page items matched, you get a page item object that actually contains multiple page items. It can take a little testing to figure out exactly what it is that was returned.
Thanks,
Ole
Similar Messages
-
View all script labels and find an object by its script label
Hello,
I have an InDesign document in which many objects get a script label. I know how to view and edit the script label of an object, but is it possible to:
1 - See a list of all the script labels of the document (as can be done with the styles for example)?
2 - Search an object in the document by its script label?If you are using OSX this AppleScript displays a list of document labels:
global labels
set labels to []
tell application "Adobe InDesign CS6"
set x to every page item of active document
repeat with i in x
if class of i is group then
my checkGroup(i)
else
my getLabel(i)
end if
end repeat
display dialog labels as string
end tell
on checkGroup(g)
tell application "Adobe InDesign CS6"
set gi to all page items of g
repeat with a in gi
if class of a is group then
my checkGroup(a)
else
my getLabel(a)
end if
end repeat
end tell
end checkGroup
on getLabel(pageitem)
tell application "Adobe InDesign CS6"
if label of pageitem is not "" and label of pageitem is not in labels then
set labels to labels & label of pageitem
end if
end tell
end getLabel -
[AS CS3] Bug? All Page Items - grouped items w labels
Can anyone confirm this behaviour for me. I would classify it as a bug, but maybe the logic for it not being a bug escapes me.
The command "all page items" is supposed to return a (flat) list of every page object, right? I would suspect that I should be able to address any object in the list. But I can only seem to address an object when it's inside of a group.
I am trying to get the text of a text frame that has a label. It may or may not be inside a group. I can certainly do a try/error block to try a script statement for objects in a group or not in a group. But I think that "all page items" should be able to handle it directly.
Here's a test script: ------
tell application "Adobe InDesign CS3"
tell document 1
get label of all page items
set myUngrouped to contents of text frame "some label" --only works when objects ungrouped, this is expected
set myText to (get contents of text frame "some label" of all page items)
--both statements work ONLY when objects grouped
set myText to (get contents of every page item of all page items whose label is "some label")
end tell
end tell
Steps:
Make a new document.
Draw a text frame. Type some text into it.
Label the frame "some label".
Draw another empty graphic or text frame.
Run script
-->result is, myText statements error out. Why is this?
Now group all items on page.
Run script.
-->result is, myUngrouped can't continue. This is expected.
Comment out myUngrouped statement
Run script.
-->result is, myText statements work OK.On 19/8/08 1:14 AM, "SuperMacGuy" <[email protected]> wrote:<br /><br />> set myText to (get contents of every page item of all page items whose label<br />> is "some label") <br /><br />The syntax is a bit tricky. The key is that all page items returns a list,<br />so what you want is certain items -- not page items -- from that list. So:<br /><br />set myText to (every item of all page items whose label is "some label")<br /><br /><br />-- <br />Shane Stanley <[email protected]>
-
CS3/CS4 - Preview of page item = Crash in rare cases
Hi,
I'm wondering about how the to draw a preview of a page item, in the most correct way. Currently im using the SnapshotUtils like:
SnapshotUtils ex(somePageItemRef,scaling,scaling);
And then:
AGMImageRecord* fpCurAGMImage = (AGMImageRecord*)ex.CreateAGMImageAccessor()->GetAGMImageRecord();
to obtain an AGMImageRecord that I can draw onto an IGraphicsPort:
PMMatrix theMatrix; // No transform
gPort->image(fpCurAGMImage, theMatrix, 0);
However, one customer(PPC Mac 10.4 CS4) had a crash in this code, as seen from the partial stack trace below:
Thread 0 Crashed:
0 AdobeAGM 0x01417418 AGMTerminate + 4143764
1 AdobeAGM 0x012b645c AGMTerminate + 2697944
2 AdobeAGM 0x012bc3e8 AGMTerminate + 2722404
3 AdobeAGM 0x012be210 AGMTerminate + 2730124
4 AdobeAGM 0x0120b8d4 AGMTerminate + 1998672
5 AdobeAGM 0x01030150 AGMTerminate + 51148
6 ...adobe.InDesign.AppFramework 0x114f48c8 GetPlugIn + 118040
7 ...adobe.InDesign.AppFramework 0x114f4b30 GetPlugIn + 118656
8 com.adobe.InDesign.MyPlugin 0x0e405778
MyCustomView::Draw (IViewPort*, __HIShape*) + 1560
I can see in the documentation that the GetAGMImageRecord function should not be called any more as of InDesign 3.0, however I cannot figure out another way of obtaining an object that i can draw onto the IGraphicsPort? Is there a more preferred solution?
I Hope somebody can help on this one
Thanks!
Kind regards TokeHi Toke,
I do not have any experience with this sort of stuff ;-(
However have you noticed the sdk sample transparencyeffect which still uses GetAGMImageRecord even with CS4. Maybe the sample code sheds some light on your problem.
Best,
Peter Schülke -
How to get another page item value in page process.
Hi all
i have an after submit process on page 32 to insert into a table.
and a page 34 where there is a region containing from page 32.
when page 32 get submitted (process as well as) it contain no value for :P34_USER_ID although i am in page 34 and :P34_USER_ID item have value.
after submit process on page 32 Type: PL/SQL anonymous block --> have code like...
INSERT INTO LETTER_ATTACH (LETTER_ID,FILENAME,ATTACHMENT,MIMETYPE,UPDATE_DATE)
SELECT :P34_USER_ID,:P32_FILE_INPUT,blob_content,mime_type,SYSDATE
FROM wwv_flow_files
WHERE NAME = :P32_FILE_INPUT;
can't find anything wrong...!!?? :(
please help me on this regards.
Roman
Edited by: user13416557 on Aug 27, 2011 1:48 PMHi,
When you are on page 32, check that there is value on page 34 item session state
http://download.oracle.com/docs/cd/E23903_01/doc/doc.41/e21674/concept_ses.htm#sthref100
Regards,
Jari -
missing adobepdf.dll file when i try to install cs3, why is that? how do i get it?
using dell xps windows 7Try http://helpx.adobe.com/creative-suite/kb/error-file-adobepdf-dll-needed.html
-
Select the Inline object by its script label
Hi Friends,
How to selct an Inline object by its label?
My Code
myDoc.pages[0].allPageItems.item("AAA").select();
But it shows the following error
myDoc.pages[0].allPageItems.item is not a function.
Regards,
JesRoberts.Hi Friend
Can you tell me what was wrong with my answer to your previous post that you didn't show any acknowledgement of it.
Did I not answer it?
Maybe before starting new post you should finish of the "finished" ones -
Page Items displayed in Oracle AS Portal
I am building a page in the Oracle Application Server Portal
that has three regions. Each region contains a Discoverer Worksheet. The layout
is such that the upper region has a worksheet graph (a) spanning 100% of the
region. Beneath this region are two regions containing one worksheet table in each
region. The worksheets have a master (b)/detail (c) relationship. The "master" (b)
worksheet is the table for the graph (a) in the upper region. It is the same
Discoverer worksheet being displayed as a graph in one region (a) and as a
table (b) in another region.
The issue that I have encountered lies in the Page Items
being part of the title of the regions. For the tables, the Page Item and values
appear just below the title of the worksheet. This is not the case for the
graph. The page items do not appear by default. To get the Page Items to appear
as part of the graph, I used the &PageItems option in Discover Plus for the
worksheet, but this causes the values to be repeated for the regions containing
tables (b) and (c).
Is there any way to turn off the Page Item as being part of
the titles in the regions containing tables? Or any way to get all three
regions to show the Page Items without them being repeated in the regions
containing tables?
Edited by: user10753869 on Dec 31, 2008 7:50 AMAny ideas on this? I have tried the custom template and changed the border="1", but that does not look very good. I want it to look more like excel, where there are titles (column headings) and within each column, each cell has a border completely around it with page items in them. Is this possible?
Thanks!
Jeff -
AS - all page items, access not allowed
I am upgrading an AppleScript from working with InDesign CS5.5 to CS6. When I recompile I get the syntax error:
"Can't set <<constant dpvtdppv>> to <<class aPgi>>.
Access not allowed."
My statement is a simple
"set pList to get all page items" within a tell myDoc section.
In reviewing the AS guide for InDesign CS6, the notes say that Chapter 4, covering all page items, was not changed in CS6. Page 113 of the guide phrases the statement without a "get", so my statement would be
"set pList to all page items". This fails with the same error. As my code gets plenty of use under CS5 and CS5.5, I suspect a dictionary error from Adobe.
Anyone with ideas?G'day
try :
set pList to every page item
m. -
Dynamic creation of page items
How can I create page items dynamic, if I have their number and their titles in a page item?
More often than not you'll run into difficulties when trying to do something like this with APEX. However, you have two options:
1 - The htmldb_item API, embedding items into a report based on the values of your previous page items.
2 - Some combination of hidden fields and conditionals that makes use of your page item values for their label text.
The former is well documented on the forum.
Rgds
Ben -
How to fix the time to refresh page items on Page load
Hi all,
When my pages load, some page items hidden are shown and when page load they are hidden again. Is there any way to keep it hidden without this time to refresh?
Thanks
Bsalvadorbsalvador wrote:
fac586,
I tryed with:
#P32_DATA_FINAL, label[for="#P32_DATA_FINAL"] {
display: none;
And only Page item was hidden. Label is still showing...could you help me?
Thanks
bsalvador
Sorry, the "#" shouldn't appear in the attribute selector. There's probably a theme CSS rule with a higher specificity on the labels, so add an !important directive to the rule:
#P32_DATA_FINAL, label[for="P32_DATA_FINAL"] {
display: none !important;
Always state which theme and template(s) you are using in a question about visual formatting or layout. Theme HTML/CSS is not always—historically never—consistent, so we need to know this information in order to determine which selectors to use. -
[AS] Script Label Items in a Group
Hi all,
I have a group of shapes that, when grouped together in Indesign, form an object. This grouped object is script labeled "special". I am trying to script label each of the individual parts of this grouped object "special" so that if users ever mistakenly ungroup the object, I can still manipulate all items with the "special" label...which is effectively my original grouped object.
The catch is that I need to do this labeling with a script because I have thousands and thousands of files I'm working with. I'd love it if something like this worked (but it doesn't):
tell application "Adobe InDesign CS3"
set theObject to page item "special" of document 1
set theShapes to every page item of all page items of theObject
set label of theShapes to "special"
end tell
The problem I keep running into is that it seems when an object is grouped, all the objects inside that group become, for all practical purposes, invisible. The line "set theshapes to every page item of all page items of theObject" returns an empty list "{ }" as though there ARE no items making up the group.
So then I thought I'd take a more tactile approach. Select it, ungroup it, label it, group it back:
tell application "Adobe InDesign CS3"
set theObject to page item "special" of document 1
select theObject
ungroup selection
set label of selection to "special"
group selection
end tell
The problem with this approach is that after ungrouping the object with a script, there is no longer a selection as there is when doing the same by hand, so trying to set the label of a selection that does not exist produces an error. Grrrrr.
Friends, I know this can be done, but I need a little outside perspective on this to help me figure this one out. As always, thanks in advance for your help!OK. Got it working but I'm not sure why. I went back to the bigger script of which the below is a part. And it works fine. I just don't understand why.
tell application "Adobe InDesign CS4"
activate
set myDocument to active document
set myPage to page pageNum of myDocument
set active page of layout window 1 to myPage
if not (exists library "Logowear_Lib.indl") then
set theFile to open tagsLib
end if
set assetPlacer to item 1 of (place asset asset "3_12:13" of library "Logowear_Lib.indl" on myDocument)
move assetPlacer to myPage
move assetPlacer to myCoordinates
set color_code_counter to 5
set color_box_counter to 1
tell myDocument
repeat color_counter times
set theColorCode to item color_code_counter of Style_List
set oldLabelName to ("CW" & color_box_counter)
set newLabelName to my makeImageName(theSap, theColorCode)
set label of (object reference of every item of all page items of page pageNum of myDocument whose label = oldLabelName) to newLabelName
set color_code_counter to (color_code_counter + 2)
set color_box_counter to (color_box_counter + 1)
end repeat
end tell
end tell -
Hi all,
Very much a newbie with InDesign Scripting, but I've managed to build a script that does exactly what I want - almost.
It opens a document, looks for a Script Label, and when it's found, it does something with the item's contents. The only problem is that some of the documents don't have a Script Label, and should therefore be ignored. I've taken this code from one of the supplied examples:
var myPageItems = myPage.pageItems.item("myScriptLabel");
var myString = myPageItems.contents;
If there are no items called "myScriptLabel", the second line will generate an error. How do I test whether the myPageItems actually contains any pageItems? I've tried all the obvious things I can think of, but have had no success. I'm sure the answer has to be a simple one.
Thanks,
BruceHi Bruce,
Hm. I thought that this would return an array, but it doesn't--it returns a single page item, even if a.) there are no objects with that label, b.) there is one object with that label, and c.) there are multiple objects with that label. If all you want to do is set some property of all of the returned page items, this is a good thing. But if you want to do something else, it makes it more difficult. Here's a basic script that shows how to deal with it. It's probably quicker than looping through every page item.
var myDocument = app.documents.add();
var myRectangle = myDocument.pages.item(0).rectangles.add({label:"myLabel"});
var myRectangle = myDocument.pages.item(0).rectangles.add({label:"myLabel"});
var myObjectList = myDocument.pages.item(0).pageItems.item("myLabel");
try{
//If the object is not valid, the following line will throw an error.
switch(myObjectList.id.constructor.name){
case("Number"):
//Do something with the object.
alert("Object ID is: " + myObjectList.id);
break;
case("Array"):
//Do something with each object (you can use objectByID to get a
//reference to each object).
for(var myCounter = 0; myCounter < myObjectList.id.length; myCounter++){
alert("Object ID is: " + myObjectList.id[myCounter]);
break;
catch(myError){alert("eh")}
Thanks,
Ole -
CS3: Rotated page item: How can I get the top-right point
Hi
I have a rotated page item. Now I should have the top-right and the bottom left point. If I get the rectangle of this page item I only have the top-left and the bottom-right point. And I can read the rotation angle.
- How can I get the missing points?
Thanks
HansAlgorithmically speaking (ie, this is NOT real code), isn't it just something like:
if page.rotationAngle == 90 then
origTopLeft = (newBottomRight.Y, newTopLeft.X);
else if page.rotationAngle == -90 then
origTopLeft = (newTopLeft.Y, newBottomRight.X);
else if page.rotationAngle == 180 then
origTopLeft = newBottomRight;
else
origTopLeft = newTopLeft; -
[CS3] How to get whether a UID is a spread, page, page item?
Hello!
I have an UID.
How can I get whether behind the UID is a spread or a page or a page item?
Alois BlaimerYou can't.
If you have a database for that UID though, you can use database->GetClass(myUID) ...
Rather than dispatching on the class ID, you better identify your required interfaces on the boss. Instantiate them (again using db+id) and if those do not exist navigate around in IHierarchy or give up gracefully. Note there are some more boss classes and stranger arrangements than you initially know - master spreads, groups, standoff, inline items, multicolumn text and so forth.
Dirk
Maybe you are looking for
-
Oracle 8.1.6.0.0 in HP-UX 11
When I am installing oracle8i on HP-UX machine, after copying all the files when trying to link the oracle protocol support 8.1.6.0.0, it pops up with the following error: "Error in invoking target ntcontab.o of makefile /oracle/orasoft/network/lib/i
-
Regarding Inheritance in BPM Objects
Hi, We are having requirement such that we are three objects: dataObject (containing one attribute - Name) , interfaceObject(containing attribute - City) and flowObject. The requirement is such that we need to inherit the properties of dataObject and
-
HT204347 iphoto no open in my mac
when i tried open iphoto in my mac, this program no open. and appers a msg: " Your iphoto library is either in use by another application or has become unreadable: Shut down and restart your computer, and then open iPhoto again. If the problem per
-
Hi- I will be purchasing my first MacBook Pro in the next week or so. I am a current college student (going into my senior year) and desperately need a new laptop. I have used PC's in the past and am ready to switch to Apple. My only question concern
-
I am not sure of the voltage of my iphone. I want to know if I need a special transformer to charge my phone in Norway. Thanks for your help.