Hi all,
I’m just starting with OmniGraffle automation, and I can’t figure out how to access mobile vertices (the ones I can move on the screen) on adjustablewedge. Is there something I’m missing here ?
My goal is to have a script creating part of pie charts, so I want to access angle (any means is ok for me).
PS I’m on iPad with latest version if anything could be different.
I don’t think that those control points on smart shapes like wedges are exposed to the scripting interface.
(you could write your own definition of them, with an arc-size parameter, but it would be one of those bring your own trigonometry affairs. In JS, Math.sinMath.cos etc)
I seem to remember writing something analogous c.10 years ago, but it was all in AppleScript.
Thanks for theses hints.
Concerning the old API, I saw the startAngle but it seems to be unavailable in recent version.
I have been able to access shapeVertices, but I have not been able to keep the shape yet. Moving all of them make a triangle and change the shape to Bézier.
If needed, I’ll be making my own « shape ».
Édit :
I’m now able to display a wedge with a given angle with Line, but I can’t fill it. In other word I actually have no idea how to make a shape from lines.
So here is a solution for creating one wedge with an angle between 0 and 180 degrees. Not so sexy but a solution.
If anyone have something clever I’m open.
I’m still missing something : is there anyway to set, with JavaScript, « keep ratio » ?
cnvs = document.windows[0].selection.canvas
cnvs.graphics.forEach(function(graphic){graphic.remove()})
var angleFalse = 60//angle wanted in degrees from 0 to 180
var R = 75//circle radius
// ger half circle
g1 = cnvs.newShape()
g1.geometry =new Rect(0,0,2*R,2*R)
g1.shape="Circle"
g2 = cnvs.newShape()
g2.geometry =new Rect(0,R,2*R,2*R)
g2.shape="Rectangle"
var g3=cnvs.combine([g2,g1],ShapeCombination.Subtract)
//get new rectangle to intersect.
//made as the right side have middle point (R,R) ie center of hal circle
var angle = -angleFalse*3.14159/180//use negative in order to have it on the right + conversion from degrees
var ca=Math.cos(angle)
var sa=Math.sin(angle)
g2 = cnvs.newShape()
g2.shape="Rectangle"
g2.shapeVertices = [new Point(R+2*R*ca,R+2*R*sa),new Point(R-2*R*ca,R-2*R*sa),new Point(R-2*R*ca-2*R*sa,R-2*R*sa+2*R*ca),new Point(R+2*R*ca-2*R*sa,R+2*R*sa+2*R*ca)]
var wedge = cnvs.combine([g3,g2], ShapeCombination.Intersect)//Voilà