> First, my scripts and SVG file are stored in the same directory as my Numbers spreadsheet. Rather than hardcode the path I want to build it programmatically based upon some manipulations of '(path to me)' for the helper script.
path to me returns the path to the running application, not the current document.
To get the current document's path, ask it for its file:
tell application "Numbers"
tell document 1
set f to its file
end tell
end tell
Now you have the path to the .numbers file. There are a couple of ways of finding the directory from there - the easiest is to ask the Finder.
Here's a revised script that looks for a file in the same folder as the .numbers file:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Numbers"
set docPath to file of document 1
tell sheet 1 of document 1
-- get the image
set myImage to image 1
-- grab its properties
tell myImage
set {fn, h, l, o, pos, refs, refv, rot, w} to its {file name, height, locked, opacity, position, reflection showing, reflection value, rotation, width}
end tell
delete myImage
end tell
end tell
-- have to drop out of Numbers here due to property name conflicts
tell application "Finder"
set d to container of (file docPath) -- find the folder containing the .numbers file
-- build a path to the image by combining the folder path and the image name
set newImagePath to (file fn of d) as text
end tell
-- and back to Numbers
tell application "Numbers"
tell sheet 1 of document 1
set newImage to make new image with properties {file:newImagePath}
tell newImage
set {height, locked, opacity, position, reflection showing, reflection value, rotation, width} to {h, l, o, pos, refs, refv, rot, w}
end tell
end tell
end tell
With a little work you could add a safeguard to verify the file exists before deleting the current one