Send to back/front of other selected object by script?
is there way script send back/front of other selected object, or target command send back/front in relation object in file? in different layers?
the answer seek in command:
pageitem move (relativeobject: object, insertionlocation: elementplacement)
here necessary elementplacement enumeration:
inside
placeatbeginning
placeatend
placebefore
placeafter
some example code :
var doc = app.activedocument; var myitem = doc.pathitems[0]; myitem.move(doc.layers[1], elementplacement.inside); // places item layer (if starts in different layer, obviously) //myitem.move(doc.layers[1], elementplacement.placeafter); // throws error "cannot move specified location" myitem = doc.pathitems.getbyname('test'); myitem.move(doc.groupitems.getbyname('my group'), elementplacement.placebefore); // moves above group named 'my group' in stacking order myitem.move(doc.groupitems.getbyname('my group'), elementplacement.placeafter); // moves below group named 'my group' in stacking order myitem.move(doc.groupitems.getbyname('my group'), elementplacement.inside); // moves inside group named 'my group', @ top of stacking order myitem.move(doc.groupitems.getbyname('my group'), elementplacement.placeatbeginning); // moves inside group named 'my group', @ top of stacking order elementplacement.inside myitem.move(doc.groupitems.getbyname('my group'), elementplacement.placeatend); // moves inside group named 'my group', @ bottom of stacking order
now let's see if can work different documents!
var doc = app.activedocument; var myitem = doc.pathitems.getbyname('test'); var newdoc = app.documents.add(); var newlayer = newdoc.layers.add(); newlayer.name = "new layer!"; myitem.move(newlayer, elementplacement.inside); // moves item specified new layer in new script-added document, although ai crashed when doing test 1st time. not sure why, it's now.
More discussions in Illustrator Scripting
adobe
Comments
Post a Comment