A further pair of related bugs with omniJS and subGraphs:
-
Copy As > JS (unlike Copy As > AS) loses all the subgraph contents if the subGraph is collapsed
- The .graphics property fails to return Subgraph contents when
.collapsed = true
Bug 1 details:
If we start with a subGraph like:
and then collapse it,
We find that while Edit > Copy As > AppleScript can successfully copy and regenerate a working subgraph, and all its contained graphics, from either its collapsed or expanded states, Copy As > Javascript is, in this build, losing all the contained graphics (in addition to copying the structure as a Group rather than a Subgraph).
Successful AS copy example:
(caveat: line 2 of the AS code currently has to be edited from
tell canvas of front window
to
tell front layer of canvas of front window
)
[details=AppleScript copy of collapsed subGraph]```AppleScript
tell application id “com.omnigroup.OmniGraffle7”
–tell canvas of front window – (Edited to following line from output of Edit > Copy As > AS)
tell front layer of canvas of front window
make new shape at end of graphics with properties {size:{131.811025, 104.881891}, text:{alignment:center, color:{0.0, 0.0, 0.0}, font:“HelveticaNeue”, text:“Generate”}, origin:{142.812994, -333.58268}, magnets:{{0, 1}, {0, -1}}}
make new shape at end of graphics with properties {size:{131.811025, 104.881891}, text:{alignment:center, color:{0.0, 0.0, 0.0}, font:“HelveticaNeue”, text:“Minimum -> Graphic”}, origin:{215.503939, -192.559059}, magnets:{{0, 1}, {0, -1}}}
make new shape at end of graphics with properties {size:{131.811025, 104.881891}, text:{alignment:center, color:{0.0, 0.0, 0.0}, font:“HelveticaNeue”, text:“Full -> Minimum”}, origin:{65.692914, -192.559059}, magnets:{{0, 1}, {0, -1}}}
make new line at end of graphics with properties {point list:{{208.71850634118, -228.700789374554}, {131.598426268448, -192.55905972552}}}
make new line at end of graphics with properties {point list:{{208.71850634118, -228.700789374554}, {281.409451086436, -192.55905972552}}}
assemble (graphics -5 through -1) with subgraph
set properties of subgraph -1 to {collapsed:true}
set properties of background of subgraph -1 to {corner radius:5, size:{100.0, 50.0}, text:{alignment:center, text:“Subgraph”}, text placement:top, origin:{56.692914, -358.58268}}
end tell
end tell
Edit > Copy As > **JavaScript** in contrast, loses all of the contents of the subGraph, retaining only its outer frame, if used when the subGraph is collapsed. The following code has failed to copy any of the subGraph contents:
var canvas = document.windows[0].selection.canvas
var g1 = canvas.newShape()
var g2 = new Group([g1])
g1.text = “Subgraph”
g1.cornerRadius = 5
g1.textSize = 12
g1.geometry = new Rect(56.69, -358.58, 100.00, 50.00)
g1.textVerticalPlacement = VerticalTextPlacement.Top
g1.fontName = “Helvetica”
g2.collapsed = true
g2.geometry = new Rect(56.69, -358.58, 100.00, 50.00)
(This is in addition to the other bug in which it uses the wrong constructor, see earlier in the thread).
**Bug 2 details**:
The deeper bug may be that the **.graphics** property of **Subgraphs** (inherited from Group) currently returns only a single-item list [just the containing frame], and loses all of the content graphics, when the subGraph is collapsed.
When **.collapsed === false** the **.graphics** property succeeds:
<img src="/uploads/default/original/2X/8/82df662fa5f87be9c3f93e9052fe9d68f286ae8f.png" width="507" height="334">
but when **.collapsed === true**, **.graphics** fails to find and return the contents of the same Subgraph – only the outer containing shape is successfully returned - contact with and knowledge of the remaining shapes is lost:
<img src="/uploads/default/original/2X/6/64fdf65cfef9a0be0687aa045f0aef760d61990a.png" width="507" height="334">