Skip to main content
February 24, 2020
Answered

Resize and move a library element of type "compound path"

  • February 24, 2020
  • 1 reply
  • 418 views

Good afternoon! I am new to writing scripts for InDesign, please help with solving this problem.

There is a script that puts the bones in a specific place on the spread and color, and also inserts one logo 2 times from the Open Library.

I had a problem indicating the location of the logo. It should be located on each stamp 3 mm higher from the bottom of the stamp. And also I can’t change the height size by 8.761 mm, respectively change the width (by default, the logotope is inserted with dimensions 28 * 33 mm). The default logo layer is called a compound path.

#target indesign

var myDoc = app.activeDocument;
var myColor = myDoc.colors.add({name:"LogoColor", model:ColorModel.process, colorValue:[100, 80, 0, 0]});
myDoc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

var myPages = myDoc.pages;
var bleedTop = myDoc.documentPreferences.properties.documentBleedTopOffset ;
var myLib = app.libraries.item("Logo.indl");
var myAsst = myLib.assets.item("logo1");


var myLayer = myDoc.layers.add ({name: "Logo", layerColor: UIColors.LIGHT_BLUE });
var logoC = myPages[0].textFrames.add({name: "Logo_cor", layer : "Logo" , LocationOptions : LocationOptions.AT_BEGINNING, reference: Page});
var otsL2 = myDoc.pages[0].marginPreferences.left;
var otsR2= myDoc.pages[0].marginPreferences.right;
var pageHeight2 = myDoc.pages[0].bounds[3] - myDoc.pages[0].bounds[1]; 

with (logoC) {
 fillColor = "LogoColor";
 strokeColor = "None";
 contentType = ContentType.unassigned;
 geometricBounds = [ - bleedTop , otsL2, 27, pageHeight2-otsR2] 
 }
var myArr1 = myAsst.placeAsset(myDoc);


var logoO = myPages[1].textFrames.add({name: "Logo_obl", layer : "Logo" , LocationOptions : LocationOptions.AT_BEGINNING, reference: Page});
var otsL3 = myDoc.pages[1].marginPreferences.left;

with (logoO) {
 fillColor ="LogoColor";
 strokeColor = "None";
 contentType = ContentType.unassigned;
 geometricBounds = [ - bleedTop , otsL3 , 27, otsL3+11.5] 
 }
var myArr2 = myAsst.placeAsset(myDoc);

Thank you for any advice!

This topic has been closed for replies.
Correct answer Laubender

Hi Nata-z,

hm. I have some trouble to understand what you are trying to do.

So your asset is a page item that has a compound path?

 

If this is the case the returned array when using method placeAsset() has the length 1:

 

myArr1.constructor.name // Should return Array
myArr2.constructor.name // Should return Array

 

 

 

myArr1.length // Should return 1
myArr2.length // Should return 1

 

 

The placed page item, the compound path object, therefore should be the first item of the returned array:

myArr1[0] and myArr2[0]

 

You could move the returned item to an x/y position or by x/y values using method move() :

 

var x = 10;
var y = 15;

myArr1[0].move( [ x , y ] ); // Move to
myArr1[0].move( undefined , [ x , y ] ); // Move by

 

 

Instead of placing the asset two times you could also duplicate the returned object.

 

Regards,
Uwe Laubender

( ACP )

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
February 24, 2020

Hi Nata-z,

hm. I have some trouble to understand what you are trying to do.

So your asset is a page item that has a compound path?

 

If this is the case the returned array when using method placeAsset() has the length 1:

 

myArr1.constructor.name // Should return Array
myArr2.constructor.name // Should return Array

 

 

 

myArr1.length // Should return 1
myArr2.length // Should return 1

 

 

The placed page item, the compound path object, therefore should be the first item of the returned array:

myArr1[0] and myArr2[0]

 

You could move the returned item to an x/y position or by x/y values using method move() :

 

var x = 10;
var y = 15;

myArr1[0].move( [ x , y ] ); // Move to
myArr1[0].move( undefined , [ x , y ] ); // Move by

 

 

Instead of placing the asset two times you could also duplicate the returned object.

 

Regards,
Uwe Laubender

( ACP )

February 24, 2020

Dear Uwe Laubender! Thank you for your quick response.

You correctly understood that the active element has a compound path.
You helped me a lot, thank you very much!