• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to start new frame in relation to the position of last frame

Explorer ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

Hi All,

 

I want to start all of my new frames in relation to the postion of the last frame I have added in the document. I want all my frames to be start with with adding two co-ordinaties for y1 and y2 position of the previous frame so how to handle that. for ex. in below example my first frame is started from postion ['3p0', '3p0', '3p0', '3p0'] and I want that my next frame should start by adding y1 and y2 co-odinates by 2 which means for frame2 geometribound position should be ['5p0', '3p0', '5p0', '3p0']  so kindly suggest how can I achieve it.

 

var document = app.documents.add();
var documentPage = document.pages.add();
var alltextFrames= documentPage.textFrames;
var frame1= alltextFrames.add();
frame1.geometricBounds = ['3p0', '3p0', '3p0', '3p0'];
frame1.contents='frame1';

var frame2= alltextFrames.add();
//frame2.geometricBounds = alltextFrames.lastItem().geometricBounds + ['2p0', '0p0', '2p0', '0p0'];
frame2.contents='frame2';

 

 

Regards,

 

TOPICS
Scripting

Views

443

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 05, 2020 Jun 05, 2020

You could use the duplicate and move method, duplicate will create a new copy of the frame and using move you can move it by a certain amount in some direction relatively. See the following code for reference

var document = app.documents.add();
var documentPage = document.pages.add();
var alltextFrames= documentPage.textFrames;
var frame1= alltextFrames.add();
var orig = app.scriptPreferences.measurementUnit 
app.scriptPreferences.measurementUnit = MeasurementUnits.PICAS
frame1.geometricBounds =
...

Votes

Translate

Translate
Explorer ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

I think I can do it with the help of following code but if anyone have any other good way to handle it then please update

 

var document = app.documents.add();
var documentPage = document.pages.add();
var alltextFrames= documentPage.textFrames;
var frame1= alltextFrames.add();
frame1.contents='frame1';
frame1.geometricBounds = ['1p0', '2p0', '4p0', '12p0'];
var frame2=addNewFrame(frame1.geometricBounds);
frame2.contents='frame2';

function addNewFrame(geometricArray)
{
var y1,x1,y2,x2;
y1=geometricArray[0]+2;
x1=geometricArray[1];
y2=geometricArray[2]+2;
x2 = geometricArray[3];

var tempFrame=alltextFrames.add();
tempFrame.geometricBounds=[y1,x1,y2,x2]
return tempFrame;
//~ alert(geometricArray);
//~ alert(tempFrame.geometricBounds);
}

Votes

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
community guidelines
Community Expert ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

You could use the duplicate and move method, duplicate will create a new copy of the frame and using move you can move it by a certain amount in some direction relatively. See the following code for reference

var document = app.documents.add();
var documentPage = document.pages.add();
var alltextFrames= documentPage.textFrames;
var frame1= alltextFrames.add();
var orig = app.scriptPreferences.measurementUnit 
app.scriptPreferences.measurementUnit = MeasurementUnits.PICAS
frame1.geometricBounds = [0, 0, 3, 3];
frame1.contents='frame1';

var nf = frame1.duplicate()
nf.move(null,[0,2])
nf.contents='frame2';
app.scriptPreferences.measurementUnit = orig 

 

-Manan

Votes

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
community guidelines
Explorer ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

LATEST

Thanks Manan,

 

Your solutions are alway valueable to me.

 

Thanks & Regards,

Ashish

Votes

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
community guidelines