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

Parent of Link

Contributor ,
Dec 23, 2018 Dec 23, 2018

Copy link to clipboard

Copied

Hi,

  

     When doing the image alignment, i have used to the below syntax to get the parent of the link and moving that object. For few images, its throwing an error. Because, parent of the link is returning as "Document".  I don't know the reason.

var PgItem = myPage.place(imgPath,[0,0],undefined,false,true,undefined);   

var parent = PgItem[0].parent;

Parent object is returning "Document" instead of "Rectangle".

TOPICS
Scripting

Views

783

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
Advocate ,
Dec 23, 2018 Dec 23, 2018

Copy link to clipboard

Copied

Can you share more information about your images or document or some screenshot to understand more clearly your challange.

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 ,
Dec 24, 2018 Dec 24, 2018

Copy link to clipboard

Copied

Hi Sudha,

strange.

Just tried your code with InDesign CC 2019 and the returned object for parent is [object Rectangle].

What's your version of InDesign?

To test your case and before running the script I placed an image so I could easily readout the link's filePath information to place the image again:

var myPage = app.documents[0].pages[0];

var file = File( app.documents[0].links[0].filePath );

var PgItem = myPage.place( file ,[0,0],undefined,false,true,undefined);

PgItem[0].parent // returns [object Rectangle]

Regards,
Uwe

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
Contributor ,
Dec 29, 2018 Dec 29, 2018

Copy link to clipboard

Copied

Hi,

     Sorry for the late reply...

     For one image is does not return "rectangle". So I have saved as the image and used to place.  After that its return correctly.  I don't know issue.

     Actual parent of the link is rectangle is it right?? but for few images when i try its returned "Oval".

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 ,
Dec 29, 2018 Dec 29, 2018

Copy link to clipboard

Copied

Hm. I thought you said that [object Document] was returned?!

In the cases when [object Oval] was returned, did you place the image on the page or did you place it to a graphic frame?

Regards,
Uwe

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
Contributor ,
Dec 30, 2018 Dec 30, 2018

Copy link to clipboard

Copied

Hi,

    For one image it was returned [object Document] - For this only i saved as the image again and ran the script.  Then the issue is fixed but i did not know the reason for the issue. So i raised this question.

     Screen Shot 2018-12-31 at 12.45.29 PM.png

    File was created by some other. When I trying its returned oval.

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 ,
Dec 31, 2018 Dec 31, 2018

Copy link to clipboard

Copied

Can you share the document here, remove all the stuff from it that is not relevant keeping only the image that returns the parent as document.

-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
Community Expert ,
Dec 31, 2018 Dec 31, 2018

Copy link to clipboard

Copied

https://forums.adobe.com/people/Sudha+K  wrote

Hi,

    For one image it was returned [object Document] - For this only i saved as the image again and ran the script.  Then the issue is fixed but i did not know the reason for the issue. So i raised this question.

     Screen Shot 2018-12-31 at 12.45.29 PM.png

    File was created by some other. When I trying its returned oval.

Hi,

I asked if you tried to place the image to a graphic frame.

For a reason. Even if the graphic frame looks like a rectangle it still could be considered an oval through the DOM.

We discussed that years ago in this forum.

Also see here the case where an oval is still considered a rectangle:

Indiscripts :: InDesign Scripting Forum Roundup #2

[JS CS5.5] How to get the constructor name of an oval?

Regards,
Uwe

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 ,
Dec 31, 2018 Dec 31, 2018

Copy link to clipboard

Copied

Hm. Can you see a difference if you do:

PgItem[0].parent.getElements()[0]

instead of simply:

PgItem[0].parent

Regards,
Uwe

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 ,
Dec 31, 2018 Dec 31, 2018

Copy link to clipboard

Copied

Scratch my last reply.

If an oval was converted to a rectangle it could still be considered an oval:

var doc = app.documents.add(),

    obj = doc.ovals.add({geometricBounds : [0,0,100,100]}),

    objId = obj.id;

obj.convertShape(ConvertShapeOptions.CONVERT_TO_RECTANGLE);

alert([

    "App Version:" +

    app.version,

    "Rectangles: " +

        doc.rectangles.length,

    "Ovals: " +

        doc.ovals.length,

    "Current object: " +

        doc.pageItems.itemByID(objId).getElements()[0].constructor.name

    ].join('\r'));

Result:

CurrentObject-Oval-4.PNG

Regards,
Uwe

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
Contributor ,
Jan 01, 2019 Jan 01, 2019

Copy link to clipboard

Copied

Hi,

     Thank you for your reply... Then in that document they may used oval. Don't know about "Document".  If i face that issue in upcoming, i will post that.

     Thank you so much...

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
Guest
Jan 07, 2022 Jan 07, 2022

Copy link to clipboard

Copied

I had this same issue. Sometimes rect[0].parent code returns [object Rectange]  and [object Document]

rect[0].parent // return [object Rectange]  and [object Document]

 

And I could replicate this issue on a demo file (check attached)

I couldn't move the images around with document object. 

Please confirm if this is a bug? any workaround would be appreciated?

Shiv5EA7_1-1641563673608.png

 

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 ,
Jan 07, 2022 Jan 07, 2022

Copy link to clipboard

Copied

Seems some document corruption. I exported the file as IDML(download link here) and then the second image gives the result as Object Polygon. However i see in your document both the images are shown as embedded but IDML shows only the first image as embedded the one with problem is removed from the link panel. How was this element placed orginally on the dicument?

-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
Community Expert ,
Jan 07, 2022 Jan 07, 2022

Copy link to clipboard

Copied

Shiv5EA7 says:

"I had this same issue. Sometimes rect[0].parent code returns [object Rectange]  and [object Document]

rect[0].parent // return [object Rectange]  and [object Document]"

 

Hi Shiv5EA7,

well, I see the same with your sample document.

Also think, that there is some corruption in the doc with that "Mother Tongues" EPS graphic.

If I cut the selected graphic to the clipboard and paste it on the page, then the parent of the graphic is [object Rectange].

 

But this does not help to maintain the original resolution of the graphic in the document when I export to IDML and open and save it with InDesign 2021.

 

Do you have an idea what the original EPS file does contain?

Pixel data? Vector data?

 

What we perhaps learn here:

Never embed any linked graphics or images.

 

Regards,
Uwe Laubender

( ACP )

 

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
New Here ,
Jan 09, 2022 Jan 09, 2022

Copy link to clipboard

Copied

LATEST

Embeded the images just for sharing it in the forum...

@Manan Joshi @Laubender I will try re-save the EPS and will keep you posted.

 

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