View Single Post
To automate the process of building a stencil of shapes with invisible margins, you could:
  1. Select some shapes with the required dimensions and magnets,
  2. run the script below.

(Adjust the value of pMargin to fine-tune the gap between arrows and shapes)

(Perhaps you could use this to derive a margin-framed version of an existing process stencil)

Code:
-- GROUP THE SELECTED SHAPE(s) WITH A LARGER (INVISIBLE) FRAMING SHAPE WHICH HAS THE SAME PATTERN OF MAGNETS
-- TO ALLOW FOR A MARGIN OF SPACE BETWEEN THE SHAPE AND THE START/END POINTS OF CONNECTING LINES

property pTitle : "Make invisible frame for selected shape(s)"
property pVer : "0.05"

property pMargin : 15

property pDoubleMargin : pMargin * 2

on run
	tell application id "OGfl"
		tell front window
			set lstSeln to selection
			if length of lstSeln < 1 then return
			
			set lstNewSeln to {}
			repeat with shpBase in lstSeln
				set shpBase to contents of shpBase
				if class of shpBase is shape then
					set {lstOrigin, lstSize, lstMagnets} to {origin, size, magnets} of shpBase
					
					-- Calculate the position and dimension for the framing shape
					repeat with i from 1 to 2
						set item i of lstOrigin to (item i of lstOrigin) - pMargin
						set item i of lstSize to (item i of lstSize) + pDoubleMargin
					end repeat
					
					-- Make a frame (copying the magnets from the base shape) and group the two
					tell its canvas
						set shpFrame to make new shape at end of graphics with properties {fill:no fill, draws stroke:false, draws shadow:false, magnets:lstMagnets, origin:lstOrigin, size:lstSize}
						set end of lstNewSeln to (assemble {shpFrame, shpBase})
					end tell
				end if
			end repeat
			
			set selection to lstNewSeln
		end tell
	end tell
end run

Last edited by RobTrew; 2013-01-03 at 06:17 AM.. Reason: Corrected z order of components to improve text handling, and allowed for multiple selections