Illustrator uses the BBAccumRotation to track an object's rotation in radians 0.51246700.
BBAccumRotation IS set if object:
- Is currently rotated - radians = value of rotation
- Was previously rotated and is currently at 0 degrees - radians = 0.000000
- Is rotated by dragging a handle
- Is rotated via Object > Transform > Rotate
- Is rotated via Properties panel > Rotate
BBAccumRotation IS NOT set if object:
- Was rotated via a script using
rotate() - Is rotated via live Effects > Distort & Transform > Transform > Rotate
- Was rotated with a live effect and expanded
The question is, is there a native / baked-in way to have rotate() set BBAccumRotation?
While it is possible to add a BBAccumRotation tag to an object, it gets treated like any custom tag - it isn't recognized by Illustrator at its rotation tag, so it isn't reflected in places like the Properties panel.
I understand I could use a custom tag to track what rotate() is doing - I'd rather not go there.
It just seems like rotate() should set BBAccumRotation and I'm hoping there's something I don't know.
If you're interested in seeing this for yourself, here are some test scripts:
Check an object's tags:
if (app.documents.length == 0 ) {
alert('Open a document to run this script.');
} else if (app.activeDocument.selection.length != 1) {
alert('Select 1 object to run this script.');
} else {
TagAlert();
}
function TagAlert() {
var iDoc = app.activeDocument;
var aObj = iDoc.selection;
var nObj = aObj.length;
for ( i = 0; i < nObj; i++ ) {
var obj = selection[0];
var aTags = obj.tags;
var nTags = aTags.length;
if (nTags == 0) {
alert('No tags.')
} else {
for ( i = 0; i < nObj; i++ ) {
var obj = aObj[0];
var aTags = obj.tags;
var nTags = aTags.length;
for ( i = 0; i < nTags; i++ ) {
tagName = aTags[i].name;
tagVal = aTags[i].value;
alert(tagName + ' ' + tagVal);
}
} // for
} // if
} // for
}; // TagAlert
Rotate an object 30 degrees:
if (app.documents.length == 0 ) {
alert('Open a document to run this script.');
} else if (app.activeDocument.selection.length != 1) {
alert('Select 1 and only 1 object to run this script.');
} else {
RotateObject();
}
function RotateObject() {
var iDoc = app.activeDocument;
var aObj = iDoc.selection;
var nObj = aObj.length;
for(i = 0; i < nObj; i++) {
aObj[i].rotate(30);
}
};
Thank you in advance :)
The
[Tags].add()method returns a Tag object that, when renamed to match a built-in tag such as, 'BBAccumRotation' is recognized by illustrator normally, such as in the properties panel.The below code rotates the first selected object -22 degrees using
.rotate()then rotates the bounding box accordingly. Note that[Tags].valuemust be converted from a String to a Number. Also note that this feature does not appear to be documented.