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
Copy link to clipboard
Copied
Workaround:
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.
Copy link to clipboard
Copied
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
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.
[...]
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()
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.
Copy link to clipboard
Copied
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
and then find it by this label - no need to label IDMS file.
Copy link to clipboard
Copied
[...]
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:
Looks like for IDMS files - there is nothing "loaded" in the PlaceGun?!?!
Copy link to clipboard
Copied
Exactly! I've been running it in UXP with the same behavior:
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
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.
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.
By @Phil 815
But it's still Snippets Collection - individual "files" - not individual items from the Snippet?
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.
By @Phil 815
What's more - just checked - you have access to ALL objects in the Snippet.
But there is something strange...
I've tried multiple times the same Snippet file and the rest - in this case - is always 5...
Copy link to clipboard
Copied
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.
By @Phil 815
"5" is the number of objects - as you can see on screenshots - those same objects are duplicated in ALL collections...
It seems to be working as I would expect on my end now
By @Phil 815
You have only ONE object in your Snippet?
Copy link to clipboard
Copied
Ah I see. Yes I'm seeing this as well