-
Notifications
You must be signed in to change notification settings - Fork 30
groups
fabiantheblind edited this page Apr 14, 2016
·
7 revisions
##Create Groups
This shows how to add a group.
// create adoc with some settings
var doc = app.documents.add({
documentPreferences: {
pageHeight: 200,
pageWidth: 200
}
});
var page = doc.pages[0]; // get the page
// add a rectangle
var rect = page.rectangles.add({
geometricBounds: [50, 0, 150, 100],
fillColor: doc.swatches[3]
});
// add aoval
var oval = page.ovals.add({
geometricBounds: [50, 100, 150, 200],
fillColor: doc.swatches[3]
});
var arr = [rect, oval]; // add them to an array
var group = page.groups.add(arr); // create a group of them
##Find Groups Here you can see how to find groups in a document.
This was written for this stackoverflow question.
// This script needs:
// - A document with one page.
// - Some groups with textframes in them on the first page.
var pg = app.activeDocument.pages[0]; // Get the first page of the current doc.
var groups = pg.groups; // Get all groups.
var tf_ingroup_counter = 0; // Init a counter for all textframes in groups.
for(var g = 0; g < groups.length;g++){
var grp = groups[g];
for(var t = 0; t < grp.textFrames.length;t++){
var tf = grp.textFrames[t];
if(tf instanceof TextFrame){
tf_ingroup_counter++; // Increment counter.
} // End loop textfraems in group.
}
} // End loop groups.
// Alert all you have found:
alert(
"I found on page " + pg.name +"\n" + pg.textFrames.length +
" text frames\nOh and there are also " +
tf_ingroup_counter+ " hidden in groups."
);
Jongware also had an answer to this question that turned out to be even better.
allframes = app.activeDocument.allPageItems;
textframes = [];
for (i=0; i<allframes.length; i++)
{
if (allframes[i] instanceof TextFrame)
textframes.push(allframes[i]);
}
alert (textframes.length);
This wiki is maintained by:
fabiantheblind
Thanks to:
- JohnDarnell for fixing lots of typos.
- jsp for fixing lots of typos.
- ltfschoen for fixing typos.
- wridgers for adding more links.
Thanks to the students from the seminar for asking all those questions and making me start this wiki.
- adinaradke
- AnitaMei
- ce0311
- coerv
- felixharle
- FerdinandP
- Flave
- marche
- monkian
- natael
- OliverMatelowski
- PDXIII
- praktischend
- schlompf
- skaim
You are awesome.
- Arrays
- Classes
- Comments
- Conditionals
- Functions
- Inspect Properties
- Loops
- Objects
- Output And Interaction
- Recursive Functions
- Inspect Properties
- Variables And Operations
- Extended JavaScript Guide
- Bridge Talk
- Create And Read Files
- ExtendScript Toolkit
- File
- Folder
- Includes JSX
- Object Watch
- Read In JSON From File And DONT Eval
- Storing Data In A Target Engine
- Target an application
- XML
- app
- Colorbrewer
- Colors And Swatches
- Delay And View
- Dialogs
- Documents
- Duplicate And Transform
- Event AfterSave
- Export IDML
- ExtendScript in InDesign Scripting DOM
- Fonts
- GeometricBounds and Coordinates
- Get named pageItems
- Graphic Lines
- Groups
- HSL Color Wheel
- Images
- Includes
- InsertionPoints
- Layers
- Line Feeds And Carrige Returns
- Masterspreads
- Matrix
- Objectstyles
- Outlines Groups Alignment
- Pages And Margins
- Pathfinder
- Placeholder Text
- Rectangles Ovals Polygons
- RulerOrigin
- Select words at insertionPoint
- Simple Find And Change Grep with FC Query
- Simple Find And Change Grep
- Simple Find And Change Text
- Spiro
- Styles
- Text Analysis ID FC
- Text Analysis
- Text Find Locations
- Text
- Transformation Matricies
- TransparencySettings
- XML creation and import