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]
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( l
...
Copy link to clipboard
Copied
Manikandand34755096, what Adobe application is your question in relation too?
Copy link to clipboard
Copied
I think it needs to be
var TFBounds=labItemTFObj[0].geometricBounds;
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 )
Copy link to clipboard
Copied
thanks ... its working and also thanks for your superb explaination ...