View Single Post
One approach would be to group the main shape with its (two or more) satellite shapes, and use a script (perhaps at a late stage of editing) to batch-correct any satellite size distortions that have arisen during resizing of the groups.

For this to work, satellite shapes would need to be tagged (with user data, as in the Inspectors > Note dialog) with their normal dimensions (before they are included in a group), so that a script can restore these dimensions later. A simple tagging script can do this to selected shapes:



Code:
-- Tag selected shape with its own dimensions

property plstTags : {"Width", "Height"}

tell application id "OGfl"
	repeat with oSeln in (selection of front window) as list
		tell oSeln
			set lstSize to size
			repeat with i from 1 to 2
				set value of user data item (item i of plstTags) to (item i of lstSize) as string
			end repeat
		end tell
	end repeat
end tell
As long as the satellite shapes have these "Width" and "Height" tags, the normal width, height and position of any such satellites can be restored at any point by selecting their enclosing groups, and running a script along the lines of:

Code:
property pTitle : "Restore satellite dimensions (and link length) within selected (resized) group(s)"
property pVer : "0.03"

property plstTags : {"Width", "Height", "LinkLength"}

tell application id "OGfl"
	repeat with oSeln in (selection of front window) as list
		tell oSeln
			if class = group then
				set refGraphics to (a reference to its graphics)
				set {lstSizes, lstOrigins, lstData} to {size, origin, user data} of refGraphics
				repeat with i from 1 to length of lstSizes
					if item i of lstData is not missing value then
						set {rWidth, rHeight} to {0, 0}
						tell item i of refGraphics
							try
								-- READ THE NORMAL DIMENSIONS FROM ANY TAGS
								set rWidth to (value of user data item (item 1 of plstTags)) as number
								set rHeight to (value of user data item (item 2 of plstTags)) as number
							end try
							
							-- IF NORMAL DIMENSIONS ARE SPECIFIED, RESTORE THEM
							if rWidth > 0 and rHeight > 0 then
								set {lstSize, lstOrigin} to {item i of lstSizes, item i of lstOrigins}
								set {rDX, rDY} to {(item 1 of lstSize) - rWidth, (item 2 of lstSize) - rHeight}
								
								-- ADJUSTING THE ORIGIN TO LEAVE THE CENTRE UNMOVED
								if rDX ≠ 0 then set item 1 of lstOrigin to (item 1 of lstOrigin) + rDX / 2
								if rDY ≠ 0 then set item 2 of lstOrigin to (item 2 of lstOrigin) + rDY / 2
								set {origin, size} to {lstOrigin, {rWidth, rHeight}}
							end if
							
							-- If a Link Length is specified, adjust distance of satellite from nearest edge of main shape
							set rLength to 0
							try
								set rLength to (value of user data item (item 3 of plstTags)) as number
							end try
							
							-- Find any horizontal or vertical (incoming or outgoing) link
							if rLength ≠ 0 then
								set {lstIn, lstOut} to {incoming lines, outgoing lines}
								set {lngIn, lngOut} to {length of lstIn, length of lstOut}
								if lngIn > 0 then
									set {rHoriz, rVert} to size of (item 1 of lstIn)
								else if lngOut > 0 then
									set {rHoriz, rVert} to size of (item 1 of lstOut)
								end if
								
								-- if a link was found then correct its length (by moving the satellite)
								if (lngIn + lngOut) > 0 then
									set lstOrigin to origin
									if rVert > rHoriz then
										set origin to {item 1 of lstOrigin, (item 2 of lstOrigin) + (rLength - rVert)}
									else
										set origin to {(item 1 of lstOrigin) + (rLength - rHoriz), item 2 of lstOrigin}
									end if
								end if
							end if
						end tell
					end if
				end repeat
			end if
		end tell
	end repeat
end tell
Attached Thumbnails
Click image for larger version

Name:	NormalDimensions.png
Views:	1302
Size:	39.6 KB
ID:	2681   Click image for larger version

Name:	Before.png
Views:	535
Size:	17.1 KB
ID:	2682   Click image for larger version

Name:	After.png
Views:	551
Size:	19.1 KB
ID:	2683  

Last edited by RobTrew; 2013-01-05 at 04:48 AM..