Highlighted

Can we take placed assets geometric Bounds

Community Beginner ,
Apr 03, 2020

Copy link to clipboard

Copied

I placed assets from library in document. After that i want to move that item, i am getting object textframe from placed assets, so i am trying to take geometricbounds but I can't. why?

 

 

var labItemTFObj=labItem.placeAsset(activeDoc);
var TFBounds=labItemTFObj.geometricBounds;
var halfHieghtOfTF=(TFBounds[2]-TFBounds[0])/2;
labItemTFObj.geometricBounds=[(MarginBottom-halfHieghtOfTF),(TFBounds[1]+2),TFBounds[2],(MarginLeft+2)];

 

 

[moved to indesign based on user's message history]

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Manikandand34755096,

 

look into DOM documentation for method placeAsset().

What it will return is always an array. Why an array? Because an asset could contain many objects that are not grouped! Because of that the array's lengths could be 1, containing one item, or greater than one, containing many items.

 

If you want to pick the first one:

var TFBounds=labItemTFObj[0].geometricBounds;

But wait. Who says, that this object has geometricBounds ?

Also check this with e.g.:

var TFBounds;
if( labItemTFObj[0].hasOwnProperty("geometricBounds"))
{
	TFBounds = abItemTFObj[0].geometricBounds;
}else{ /* alert the user and stop the script*/ };

 If you wonder what object could be an asset and has no geometricBounds, then think of Guides.

 

Hm…

All this said: DOM documentation is not clear about what actually is returned by method placeAsset():

The older docu says Array of any is returned, the newer one is saying Varies. Strange.

 

http://jongware.mit.edu/idcs6js/pc_Asset.html#placeAsset

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Asset.html#d1e298313__d1e298609

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Libraries

Views

955

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

Can we take placed assets geometric Bounds

Community Beginner ,
Apr 03, 2020

Copy link to clipboard

Copied

I placed assets from library in document. After that i want to move that item, i am getting object textframe from placed assets, so i am trying to take geometricbounds but I can't. why?

 

 

var labItemTFObj=labItem.placeAsset(activeDoc);
var TFBounds=labItemTFObj.geometricBounds;
var halfHieghtOfTF=(TFBounds[2]-TFBounds[0])/2;
labItemTFObj.geometricBounds=[(MarginBottom-halfHieghtOfTF),(TFBounds[1]+2),TFBounds[2],(MarginLeft+2)];

 

 

[moved to indesign based on user's message history]

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Manikandand34755096,

 

look into DOM documentation for method placeAsset().

What it will return is always an array. Why an array? Because an asset could contain many objects that are not grouped! Because of that the array's lengths could be 1, containing one item, or greater than one, containing many items.

 

If you want to pick the first one:

var TFBounds=labItemTFObj[0].geometricBounds;

But wait. Who says, that this object has geometricBounds ?

Also check this with e.g.:

var TFBounds;
if( labItemTFObj[0].hasOwnProperty("geometricBounds"))
{
	TFBounds = abItemTFObj[0].geometricBounds;
}else{ /* alert the user and stop the script*/ };

 If you wonder what object could be an asset and has no geometricBounds, then think of Guides.

 

Hm…

All this said: DOM documentation is not clear about what actually is returned by method placeAsset():

The older docu says Array of any is returned, the newer one is saying Varies. Strange.

 

http://jongware.mit.edu/idcs6js/pc_Asset.html#placeAsset

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Asset.html#d1e298313__d1e298609

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Libraries

Views

956

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
Apr 03, 2020 0
Adobe Employee ,
Apr 03, 2020

Copy link to clipboard

Copied

Manikandand34755096, what Adobe application is your question in relation too?

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...
Apr 03, 2020 0
Adobe Community Professional ,
Apr 03, 2020

Copy link to clipboard

Copied

I think it needs to be

var TFBounds=labItemTFObj[0].geometricBounds;

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...
Apr 03, 2020 0
Adobe Community Professional ,
Apr 03, 2020

Copy link to clipboard

Copied

Hi Manikandand34755096,

 

look into DOM documentation for method placeAsset().

What it will return is always an array. Why an array? Because an asset could contain many objects that are not grouped! Because of that the array's lengths could be 1, containing one item, or greater than one, containing many items.

 

If you want to pick the first one:

var TFBounds=labItemTFObj[0].geometricBounds;

But wait. Who says, that this object has geometricBounds ?

Also check this with e.g.:

var TFBounds;
if( labItemTFObj[0].hasOwnProperty("geometricBounds"))
{
	TFBounds = abItemTFObj[0].geometricBounds;
}else{ /* alert the user and stop the script*/ };

 If you wonder what object could be an asset and has no geometricBounds, then think of Guides.

 

Hm…

All this said: DOM documentation is not clear about what actually is returned by method placeAsset():

The older docu says Array of any is returned, the newer one is saying Varies. Strange.

 

http://jongware.mit.edu/idcs6js/pc_Asset.html#placeAsset

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Asset.html#d1e298313__d1e298609

 

Regards,
Uwe Laubender

( ACP )

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...
Apr 03, 2020 0
Community Beginner ,
Apr 10, 2020

Copy link to clipboard

Copied

thanks ... its working and also thanks for your superb explaination ...

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...
Apr 10, 2020 0