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

PlaceGun does not have reference to idms textframe

New Here ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

Hi,

I'm trying to place a textframe from an idms file into an indesign document. The actual loadPlaceGun() operation seems to work fine as I'm able to paste the textframe on the page. However, I also want to have a reference to that textframe. I was trying to accomplish this by using 

placeGun.pageItems.everyItem().getElements(), but it doesn't return any elements. I find this odd because I'm using the same method when inserting images and it works fine, so I'm not sure what the issue is. Any ideas would be appreciated!
Phil36455279k31w_1-1712001901949.png

 

Phil36455279k31w_0-1712001868571.png

 

Thanks
TOPICS
Bug , How to , Scripting , UXP Scripting

Views

204

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

Workaround:

  1. Add an empty page at the end of the document.
  2. Place your IDMS file there.
  3. Get a reference to the 1st - and only - object on that page.

 

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
Explorer ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

Hi Robert,

Thanks for the suggestion. Unfortunately that's not going to work for my needs; I can't have an empty page hanging around at the end of the document. At that point I might as well embed a script label in the IDMS that I load so I can look it up with that label after placing it on the page. I'm surprised this hasn't been fixed as it's a tool that was available in Extendscript so it's not a new feature.

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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

@Phil 815

 

What is the reason that you can't add an empty page at the end - and then delete it?

 

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
Explorer ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

@Robert at ID-Tasker without getting too into the weeds, the script we're writing is for production use by our stakeholders. So we don't want to require them to manually remove a page in their workflows (stakeholders will also be working with a dynamic number of pages at any given time, so it would be difficult to programmatically remove this without a risk of data loss).

 

Like I mentioned, I think we may be able to get something that works by adding a script label in the textframe of the idms that uniquely identifies it so we can find it on the page after rendering and continue to edit from there... it's just unfortunate that we have to do this sort of workaround  

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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

quote

@Robert at ID-Tasker without getting too into the weeds, the script we're writing is for production use by our stakeholders. So we don't want to require them to manually remove a page in their workflows.

[...] 


By @Phil 815

 

???

 

Who said anything about removing manually?

The same way as you are adding page -

 

myDoc.pages.add()

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Pages.html#d1e205795__d1e205844

 

the same way you can remove it:

 

myDoc.pages[-1].remove()

 

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
Explorer ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

Thanks Robert!

Agreed that this would allow us to get the reference, but it's still not the workflow we're looking for. We want the user to be able to place the textframe in a spot they choose, not on a separate page. So I think we'd be losing the benefit of the placeGun even though we would have a reference to the textframe. Having said that I'll try some form of your suggestion today and get back. I'm also going to try the script label idea I mentioned. 

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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

@Phil 815 

 

Right, PlaceGun.

 

It works in VB - but the moment user clicks somewhere on the page - you no longer have a working reference to the "loaded" object...

 

So you would have to "label" it:

Function LoadPlaceGun()
   Dim qqq As Variant
   
   Call myInDi.ActiveDocument.PlaceGuns.LoadPlaceGun("C:\temp\qqq.svg", False)
   Set qqq = myInDi.ActiveDocument.PlaceGuns.PageItems
   qqq.Item(1).Label = "QWE"
End Function

 

RobertTkaczyk_2-1712071806017.png

 

and then find it by this label - no need to label IDMS file.

 

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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

quote

@Phil 815 

 

[...]

and then find it by this label - no need to label IDMS file.


By @Robert at ID-Tasker

 

OK, I've checked with IDMS file:

 

RobertTkaczyk_1-1712072243839.png

 

Looks like for IDMS files - there is nothing "loaded" in the PlaceGun?!?!

 

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
Explorer ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

Exactly! I've been running it in UXP with the same behavior:

Phil815_0-1712072941363.png

 

It's so odd beacuse I'm still able to "place" the texframe on the page like an image, but I'm not able to access it from the placeGun object like I am with an image even though the documentation says I should be able to. I've tried with placeGun.pageItems and placeGun.textFrames 
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PlaceGun.html

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
Explorer ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

@Robert at ID-Tasker I think I found it. It looks like it's hiding in snippets. However, I think it should also be in PageItems so I'm not convinced this isn't a bug as well.

 

Phil815_0-1712073643905.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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

quote

@Robert at ID-Tasker I think I found it. It looks like it's hiding in snippets. However, I think it should also be in PageItems so I'm not convinced this isn't a bug as well.

 

Phil815_0-1712073643905.png


By @Phil 815

 

But it's still Snippets Collection - individual "files" - not individual items from the Snippet? 

 

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 ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

quote

@Robert at ID-Tasker I think I found it. It looks like it's hiding in snippets. However, I think it should also be in PageItems so I'm not convinced this isn't a bug as well.

 

Phil815_0-1712073643905.png

 

By @Phil 815

 

What's more - just checked - you have access to ALL objects in the Snippet.

 

But there is something strange...

 

RobertTkaczyk_0-1712134938481.png

 

RobertTkaczyk_3-1712135428398.png

RobertTkaczyk_4-1712135489811.png

 

I've tried multiple times the same Snippet file and the rest - in this case - is always 5...

 

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
Explorer ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

Yeah you have to navigate to the specific object type you're inserting which it unfortunate. I'm not sure about this count of 5 that you're seeing. It seems to be working as I would expect on my end now

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 ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

quote

Yeah you have to navigate to the specific object type you're inserting which it unfortunate. I'm not sure about this count of 5 that you're seeing.


By @Phil 815

 

"5" is the number of objects - as you can see on screenshots - those same objects are duplicated in ALL collections...

 

quote

It seems to be working as I would expect on my end now


By @Phil 815

 

You have only ONE object in your Snippet?

 

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
Explorer ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

LATEST

Ah I see. Yes I'm seeing this as well

Phil815_0-1712166919370.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