-
Notifications
You must be signed in to change notification settings - Fork 9
Inspect Properties
Fabian Morón Zirfas edited this page Jun 13, 2025
·
4 revisions
/*
You can inspect objects by using
toSource()
and
toString()
*/
var o = {
a: "Hello World",
b: 5.5,
c: true,
x: [1, 2, 3],
}; //Object
alert(o.toSource());
alert(o.toString());If you want to output something into the Console of the ESTK
use $.writeln()
$.writeln("Hello World");// use this in ESTK
Every object has lots of and different properties. You can look for them in the references mentioned in the first session. Also you can inspect them directly with the Example script inspectProperties.jsx.
main();
/*
Main Function everything is in here
*/
function main() {
// store the reference to an object in a variable
//~ var ref = app.activeDocument.paragraphStyles.item(1);
// var ref = app.activeDocument.pages.item(0);
var ref = app.fonts.item(0);
// you could also use the selection
// if(app.selection.length > 0){
// var obj = app.selection[0];
// };
var insepction_result = inspectObjectProps(ref);
var res = null;
res = confirm("Write output to file?", false, "Title WIN only");
if (res == true) {
writeArray(insepction_result, ref);
} else if (res == false) {
alert("Properties of " + String(ref) + "\n" + insepction_result.join("\n"));
}
}
/**
* This inspects the object by looping it and
* turning the result to an string
*
*/
function inspectObjectProps(obj) {
var arr = new Array();
for (var key in obj.properties) {
arr.push("'" + key + "':" + obj[key]);
}
return arr;
}
function writeArray(arr, obj) {
//select an output folder
var newLocation = Folder.selectDialog("Select a output folder...");
// give the file a unique name
var timestamp = Number(new Date());
// now build the filename. fn you get it?
var fn = "file " + timestamp + String(obj);
// now set the output folder
// fs means file system
// tf means target folder
var tf = newLocation.fsName;
// add the new file under the location to the file system
var txtFile = new File(tf + "/" + fn + ".txt");
var out;
if (txtFile != "") {
//Open the file for writing.
out = txtFile.open("e", undefined, undefined);
txtFile.encoding = "UTF-8";
txtFile.lineFeed = "Unix"; //convert to UNIX lineFeed
// txtFile.lineFeed = "Windows";
// txtFile.lineFeed = "Macintosh";
}
if (out != false) {
for (var i in arr) {
txtFile.writeln(arr[i]);
}
txtFile.close();
txtFile.execute();
}
}This wiki is mostly maintained by:
ff6347
Thanks to:
- JohnDarnell for fixing lots of typos.
- jsp for fixing lots of typos.
- ltfschoen for fixing typos.
- wridgers for adding more links.
- EugenTepin for several improvements.
- vamitul for improvements.
- abandonedbywolves for adding an example.
- Travis Weston
- Andy Dayton
Thanks to the students from my seminars 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
- Executing Shell Commands
- ExtendScript Toolkit
- File
- Folder
- Includes JSX
- Object Watch
- Read CSV
- Read In JSON From File And DONT Eval
- Storing Data In A Target Engine
- Target an application
- XML
- Isolate Layers With the Shy Setting
- Layer Duration Change
- Render And System Call
- Rename Layers
- SourceText to Keyframes from Array
- SourceText
- System Call
- app
- Colorbrewer
- ColorGroups
- 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
- Locked PageItems
- loops vs everyItem
- Masterspreads
- Matrix
- Objectstyles
- Outlines Groups Alignment
- Pages And Margins
- Pathfinder
- Placeholder Text
- Rectangles Ovals Polygons
- RulerOrigin
- Scripting Labels
- Select words at insertionPoint
- Simple Find And Change Grep with FC Query
- Simple Find And Change Grep
- Simple Find And Change Text
- Spiro
- Styles
- Table Cells
- Text Analysis ID FC
- Text Analysis
- Text Find Locations
- Text
- Transformation Matricies
- TransparencySettings
- XML creation and import