Copy link to clipboard
Copied
I use standard script MakeGrid.jsx (InDesign), make Grid boxes.
Hoe can I change fontsize, fonttype, textcolor etc. for text in those boxes?
I tried several ways (blue text eg.), but nothing changes the text... Text comes in boxes, thats OK, but I can't change its font etc.
default code (at line 131 ...):
if(myRetainFormatting == true){
myNewObject = myObject.duplicate();
myNewObject.geometricBounds = [myY1, myX1, myY2, myX2];
}
replaced code (at line131 ...):
if(myRetainFormatting == true){
myNewObject = myObject.duplicate();
myNewObject.geometricBounds = [myY1, myX1, myY2, myX2];
tmp = myNewObject.textFrames.add(
{
geometricBounds :[myY1, myX1, myY2, myX2],
strokeWidth : 0,
size:30,
fillColor : "None",
contents : "some text"
});
}
2 Correct answers
You need to check if myNewObject is a textFrame before trying to access parentStory. MakeGrid can work on several different objects.
if (
if(myRetainFormatting == true){
myNewObject = myObject.duplicate();
myNewObject.geometricBounds = [myY1, myX1, myY2, myX2];
if (myNewObject instanceof TextFrame) {
myNewObject.parentStory.pointSize = 20
}
}
That explains it, i was always trying it with a single textframe selection. Good catch Brian
-Manan
Copy link to clipboard
Copied
Hi,
The code myObject.duplicate() creates the new textframe. You can alter its properties by using the myNewObject var. For ex changing the font size of the new frames the code would be something like
if(myRetainFormatting == true){
myNewObject = myObject.duplicate();
myNewObject.geometricBounds = [myY1, myX1, myY2, myX2];
myNewObject.parentStory.pointSize = 20
}
You can change other properties as well by looking at what properties are available for story object
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Story.html
-Manan
Copy link to clipboard
Copied
@Manan,
Thanks for answer... however it does not work for me, see error message below.
Is it about an other version of InDesign ? (I have CS6).
code replaced= your suggestion above
Message:
Copy link to clipboard
Copied
See the following discussions for examples that should help you
https://community.adobe.com/t5/indesign/script-for-changing-font/m-p/10984673?page=1
https://community.adobe.com/t5/indesign/how-script-create-text-frame/m-p/9784168?page=1
-Manan
Copy link to clipboard
Copied
I don't have access to CS6 but we can target the older script version and i did that, all seems to be working fine for me. CS6 does have the parentStory property. See the following
http://jongware.mit.edu/idcs6js/pc_TextFrame.html
Run the following code and see what you get
alert(app.scriptPreferences.version)
For CS6 it should be 8, i set it to 8 on my end and it worked fine. See the code running on my end and check if you notice something different in what you have edited
-Manan
Copy link to clipboard
Copied
@Manan,
Version = 8.0
by the way ... is there a possibility to record a serie key strokes so that makes/records a script... That will help me to learn and see the things work?
ActionRecorderExtension.zxp (from Rorohiko does not work).
Copy link to clipboard
Copied
Note that ActionRecorder is very old. It was using the old CSXS technology (Air/Flash based) which is not supported any more, and the signing certificates on it have long gone stale.
At the time we were very hopeful and sank a lot of time, effort and resources into ActionRecorder, but we never found any takers, and when the move to CEP was made, we could not afford rebuilding it from scratch, so we had to abandon the project...
Copy link to clipboard
Copied
Do you really need the changes in the script?
Or is it possible to create an new Object Style with an Paragraph Style.
Then run your MakeGrid.jsx. The text boxes are still selected --> now simply apply your new created Object Style.
Copy link to clipboard
Copied
@pixxxel_schubser
Thanks... first: I'am a beginner in InDesign.
Although I can program, scripting in InDesign is different.
In addition, I would more like to make a one-touch-button because the end result is for non-experienced people who do not have to do difficult things.
Furthermore: font, color, size etc. should still be a basic occurrence in a script?! I was looking for scripts that change fonts etc. But finding a good example is difficult. Maybe someone has a simple script that changes the font, size and color and makes it available? And I can make progress.
Error message (above): if I read correctly ... there is something with the object and not with "parentStory" .. isn't it?
So, how can I check if my InDesign CS6-V8 has a "parentStory".
or ... should I use a different type of object in the script? As said ... I'm too inexperienced with InDesign.
Copy link to clipboard
Copied
I am not aware of any action recorder for InDesign. However i looked into my archives and was able to locate an installation of CS6, and the code works flawlessly for me. See the screengrab
Are you doing something different from what i am doing? There has to be something different
-Manan
Copy link to clipboard
Copied
You need to check if myNewObject is a textFrame before trying to access parentStory. MakeGrid can work on several different objects.
if (
if(myRetainFormatting == true){
myNewObject = myObject.duplicate();
myNewObject.geometricBounds = [myY1, myX1, myY2, myX2];
if (myNewObject instanceof TextFrame) {
myNewObject.parentStory.pointSize = 20
}
}
Copy link to clipboard
Copied
That explains it, i was always trying it with a single textframe selection. Good catch Brian
-Manan
Copy link to clipboard
Copied
@Manan Joshi + @Brianp311
YES, I was focused on the script commands. I used an empty frame, no text in it. After I type some text in it "parentStory" works well!.
Both thanks.
Copy link to clipboard
Copied
Hi Jan,
additionally to what Brian and Manan said, visit the DOM documentation for InDesign CS6 :
Compiled by Jongware for online and offline use. Also for various versions of InDesign, Illustrator and PhotoShop, also FrameMaker:
http://www.jongware.com/idjshelp.html
Or the one compiled by Gregor Fellenz for online use:
https://www.indesignjs.de/extendscriptAPI/indesign8/#about.html
And yes, here we have it, property parentStory with text frames:
http://jongware.mit.edu/idcs6js/pc_TextFrame.html#parentStory
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
@Laubender....
Thanks.