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

Short cut coding

Participant ,
Nov 11, 2014 Nov 11, 2014

Hi All,

The below coding is to create margins for master spreads. If any shortcut coding for this.

See my coding below

var mydoc = app.activeDocument;

mydoc.masterSpreads.item(0).

pages.item(0).marginPreferences.top = "6p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.left = "3p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.bottom = "6p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.right = "3p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.top = "6p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.left = "3p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.bottom = "6p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.right = "3p";

alert("Done")

Regards,

Vetha

TOPICS
Scripting
739
Translate
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

Mentor , Nov 11, 2014 Nov 11, 2014

Or for real brevity: 😉

app.activeDocument.masterSpreads[0].pages.itemByRange(0,1).properties={marginPreferences:{top:'6p',left:'3p',bottom:'6p',right:'3p'}};

Just one point worth noting that using square bracket [0] instead of .item(0) is quite a bit more convenient.

P.s. Marc, Sorry for the plagiary.

Regards

Trevor

Translate
Community Expert ,
Nov 11, 2014 Nov 11, 2014

That code should work just fine as it is, although I must admit it's not how I would do it. Then again ...

As you are clearly a beginner in Javascripting-for-InDesign, I strongly suggest you should not attempt to write any fancy code until you have a clear understanding of the basics. First thing to learn is how to write scripts that do what you need, without using any shortcuts. They will backfire if you don't know what you are doing.

Translate
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
Participant ,
Nov 11, 2014 Nov 11, 2014

Thanks a lot. Like this replies are useful to me...

Translate
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
Guide ,
Nov 11, 2014 Nov 11, 2014

Anyway, here is the track I would suggest:

const MY_PAGE_SETTINGS = {

    marginPreferences: { top:'6p', left:'3p', bottom: '6p', right: '3p' },

    // etc

    };

   

var mydoc = app.activeDocument;

mydoc.masterSpreads[0].pages.itemByRange(0,1).properties = MY_PAGE_SETTINGS;

alert("Done");

@+

Marc

Translate
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
Mentor ,
Nov 11, 2014 Nov 11, 2014

Or for real brevity: 😉

app.activeDocument.masterSpreads[0].pages.itemByRange(0,1).properties={marginPreferences:{top:'6p',left:'3p',bottom:'6p',right:'3p'}};

Just one point worth noting that using square bracket [0] instead of .item(0) is quite a bit more convenient.

P.s. Marc, Sorry for the plagiary.

Regards

Trevor

Translate
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
Participant ,
Nov 11, 2014 Nov 11, 2014
LATEST

Hi Trevor,

Thanks, I easy to understand. And also I learn new coding from Marc. Thanks a lot both of them.

Regards,

Vetha

Translate
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
Participant ,
Nov 11, 2014 Nov 11, 2014

Thanks

Translate
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