Highlighted

How add text to frames in script: MakeGrid.jsx

Explorer ,
May 23, 2020

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"
});
}

 

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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
 }
}
TOPICS
Scripting

Views

845

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How add text to frames in script: MakeGrid.jsx

Explorer ,
May 23, 2020

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"
});
}

 

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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
 }
}
TOPICS
Scripting

Views

846

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 23, 2020 0
Adobe Community Professional ,
May 23, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 1
Explorer ,
May 23, 2020

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:

Z-Text-Sample.jpg

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Adobe Community Professional ,
May 23, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Adobe Community Professional ,
May 23, 2020

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

https://www.dropbox.com/s/2xofaqrbjjndi0g/screen%20recording%202020-05-23%20at%203.10.23%20pm.mov?dl...

 

-Manan

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Explorer ,
May 23, 2020

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).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Contributor ,
May 26, 2020

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 26, 2020 0
Most Valuable Participant ,
May 23, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Explorer ,
May 23, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0
Adobe Community Professional ,
May 23, 2020

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

https://www.dropbox.com/s/j1u359nyl3aw9p5/screen%20recording%202020-05-23%20at%208.31.48%20pm.mov?dl...

 

Are you doing something different from what i am doing? There has to be something different

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2020 0