InDesign CS4 - Place asset into rectangle frame

Hi all,

I am having an issue placing an image from a library into a rectangle frame. I can get an asset to the page OR get a file into the frame but I can’t seem to get an asset into a frame. Here is what I have:

repeat with curPage from 1 to (count of myPages) -- repeat for each page in a spread of pages myPages
			set myArtwork to (every item of master page items of item curPage of myPages whose label contains designFrame)
				if not myArtwork = {} then  -- make sure there rectangles to override
					set myArtwork to override myArtwork destination page item curPage of myPages

               				-- this is the problem area
					set myAsset to name of asset (name of item newDesignCount of userDesigns) of theLibrary as string  -- item newDesignCount of UserDesigns is the item in a list of assets and theLibrary is 'library <myLibFile>'
					set newAsset to place asset asset myAsset of theLibrary on myArtwork
				end if
		end repeat

I am not sure if you can place an asset into a rectangle (myArtwork) or you need to place it somewhere first like the clipboard and then paste into the rectangle.

Any takers on helping me? I am pulling my hair out on this one!

Thanks,

Tom

Hi, Tom. Library assets can only be placed on the document or text. You could place the asset and then cut & paste into a new frame, but that’s going to be slower than just placing images from a file path.

Hmmm I was afraid of that. My current workaround is similar to what you suggested. I override the frame from the master page, place the image on the page with the same location and dimensions and then remove the applied frame. It is quite slow using this method as you suggested. The reservation I have in regards to a file is they are kinda scattered all over the place. The library represents a good way to abstract the filesystem element so I can consistently place things from one location. Here is the code I ended up with (that works):


                                      if not myFrameList = {} then
							repeat with curFrame from 1 to count myFrameList -- iterate for each matching frame of current page
								set myItem to item curFrame of myFrameList
								try
									set myItem to override myItem destination page item curPage of myPages
									set myBounds to geometric bounds of myItem -- get location details of frame as it was on master page
								end try
								if not myItem = {} then
									set placedAsset to place asset asset (name of item newDesignCount of userDesigns) of theLibrary on myDoc
									set mynewFrame to item 1 of placedAsset -- place asset returns an array so select the item in the array
									set label of mynewFrame to label of myItem -- be sure to set this back to the master style
									move mynewFrame to item curPage of myPages
									set locked of myItem to false
									delete myItem -- now that we have deleted the one from the master
									try
										set myObjectStyle to object style ospArtwork of myDoc
									on error --The object style did not exist, so create it. Potentially useful futureproofing
										set myObjectStyle to make object style with properties {name:ospArtwork}
									end try
									set myFrame to mynewFrame
									set applied object style of myFrame to myObjectStyle
									set geometric bounds of myFrame to myBounds
									fit myFrame given fill proportionally
									fit myFrame given center content
								end if
							end repeat
						end if

Does anybody have other ideas on how to do this? I thought about using bridge but I don’t know if that will be any better than simply finding and placing the file from the hundred plus folders I’ve got.

Cheers,

Tom

If you are placing an image why not place that directly? If it is in the library then to link up properly you know the path to the image so going through the library is adding steps anyway.

I thought of this but couldn’t find the property within the library that points to the source file. Do you know how to call that through the library item?

Cheers,

Tom

There isn’t a property in the library to get that directly. You could create a separate InDesign file as your library or make a master page to act as the library. If all you are doing is placing photo’s into picture frames then to get started I would create a separate document and place them from the library into that. Then use a script to read the paths and build either a list to paste into your script.

For a more flexible approach write a text file that could be read in when needed. This if another project comes up where you need to do the same thing instead of building a library you just drag the images into a blank ID doc, run a script to build your paths list file and load that into the place script. To make sure you are not constantly being asked for the paths file make a property to store the last document name and if the name is not changed then it runs without prompting for the file. Also store the data in a property so that you don’t need to reload that unless the document name changes.

As for the data formating I would probably make a text file similar to this:

Then parse that into a list of records: