forked from nvkelso/illustrator-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix find and replace script when objects are renamed
See nvkelso#4
- Loading branch information
Showing
1 changed file
with
30 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
///////////////////////////////////////////////////////////////// | ||
//Copy to Object(s) v5 -- CS,CS2,CS3 | ||
// Hacked again by Nathaniel Vaughn Kelso @ 7 June 2007 | ||
// [email protected] | ||
// Hacked again by Nathaniel Vaughn Kelso @ 7 June 2007 | ||
// [email protected] | ||
// "Multiple-object-replacement" hack by Iain Henderson | ||
// [email protected] | ||
// [email protected] | ||
// | ||
//>=-------------------------------------- | ||
// User selects two (or more) objects: | ||
|
@@ -15,10 +15,10 @@ | |
//Version 4 update: Deselects everything but source object | ||
// --this makes it easy to delete the source object if you wish, | ||
// -- also this makes the older "Replace-Object" script obsolete. | ||
//Version 5 update: option to NOT transform to fit original shape | ||
// -- with additional option flag to register the replacing shape to | ||
// the being-replaced shape's center instead of upper-left corner | ||
//TODO: add flag to delete "master" replacing symbol on completion | ||
//Version 5 update: option to NOT transform to fit original shape | ||
// -- with additional option flag to register the replacing shape to | ||
// the being-replaced shape's center instead of upper-left corner | ||
//TODO: add flag to delete "master" replacing symbol on completion | ||
//>=-------------------------------------- | ||
// JS code (c) copyright: John Wundes ( [email protected] ) www.wundes.com | ||
//copyright full text here: http://www.wundes.com/js4ai/copyright.txt | ||
|
@@ -35,10 +35,10 @@ if (documents.length>0) { | |
//initialize vars | ||
// | ||
//******************************************************* | ||
// Toggles for scaling object, fitting to original, offset to center | ||
// Toggles for scaling object, fitting to original, offset to center | ||
//toggle for scaling stroke: set to true to scale stroke. | ||
var scaledStroke = true; // when fitting original dimensions, scale the stroke | ||
var scaledObject = true; // fit to original dimensions | ||
var scaledStroke = true; // when fitting original dimensions, scale the stroke | ||
var scaledObject = true; // fit to original dimensions | ||
var scalingCentered = false; // register with center of being-replaced object | ||
//******************************************************* | ||
//create stroke Array | ||
|
@@ -69,23 +69,23 @@ if (documents.length>0) { | |
|
||
for (var i=0; i < mySelection.length; i++) { | ||
eval('subArray' + i + '=' + 'new Array()'); | ||
eval('subArray' + i + '["object"]' + '=' + mySelection[i]); | ||
eval('subArray' + i + '["object"]' + '="' + mySelection[i] + '"'); | ||
initBounds = mySelection[i].geometricBounds; | ||
ul_x = initBounds[0]; | ||
ul_y = initBounds[1]; | ||
lr_x = initBounds[2]; | ||
lr_y = initBounds[3]; | ||
mySelWidth = (lr_x-ul_x); | ||
mySelHeight = (ul_y-lr_y); | ||
mySelPos = [ul_x, ul_y]; | ||
mySelOffsetXpos = (ul_x + mySelWidth / 2 - oSelWidth / 2); | ||
mySelPos = [ul_x, ul_y]; | ||
mySelOffsetXpos = (ul_x + mySelWidth / 2 - oSelWidth / 2); | ||
mySelOffsetYpos = (ul_y - mySelHeight / 2 + oSelHeight / 2); | ||
eval('subArray' + i + '["width"]=' + mySelWidth); | ||
eval('subArray' + i + '["xpos"]=' + ul_x); | ||
eval('subArray' + i + '["ypos"]=' + ul_y); | ||
eval('subArray' + i + '["height"]=' + mySelHeight); | ||
eval('subArray' + i + '["height"]=' + mySelHeight); | ||
eval('subArray' + i + '["offsetXpos"]=' + mySelOffsetXpos); | ||
eval('subArray' + i + '["offsetYpos"]=' + mySelOffsetYpos); | ||
eval('subArray' + i + '["offsetYpos"]=' + mySelOffsetYpos); | ||
|
||
eval('alterObjectArray.push(subArray' + i + ')'); | ||
} | ||
|
@@ -112,27 +112,27 @@ if (documents.length>0) { | |
newGroup.move(docRef, ElementPlacement.PLACEATEND); | ||
mySelection[0].duplicate(newGroup, ElementPlacement.PLACEATEND); | ||
} | ||
markStroked(newGroup); | ||
|
||
markStroked(newGroup); | ||
|
||
// Check to see if the replacing object should be scaled down/up to fit the dimensions of the being-replaced object | ||
if ( scaledObject == true) { | ||
if ( scaledObject == true) { | ||
eval('newGroup.position = [alterObjectArray['+i+']["xpos"], alterObjectArray['+i+']["ypos"]]'); | ||
eval('newGroup.height = alterObjectArray['+ i +']["height"]'); | ||
eval('newGroup.width = alterObjectArray[' + i +']["width"]'); | ||
} else { | ||
|
||
// Check to see if the replacing object should be registered to the upper left corer of | ||
// the being-replaced objects or if it should be centered on the being-replaced object | ||
if( scalingCentered == true ) { | ||
eval('newGroup.width = alterObjectArray[' + i +']["width"]'); | ||
} else { | ||
|
||
// Check to see if the replacing object should be registered to the upper left corer of | ||
// the being-replaced objects or if it should be centered on the being-replaced object | ||
if( scalingCentered == true ) { | ||
eval('newGroup.position = [alterObjectArray['+i+']["offsetXpos"], alterObjectArray['+i+']["offsetYpos"]]'); | ||
} else { | ||
eval('newGroup.position = [alterObjectArray['+i+']["xpos"], alterObjectArray['+i+']["ypos"]]'); | ||
} | ||
} | ||
|
||
} else { | ||
eval('newGroup.position = [alterObjectArray['+i+']["xpos"], alterObjectArray['+i+']["ypos"]]'); | ||
} | ||
} | ||
|
||
mySelection[i].remove(); | ||
//restroke with new proportions | ||
scaleStroke(strokeArray, propDiff); | ||
scaleStroke(strokeArray, propDiff); | ||
} | ||
slen = selection.length; | ||
|
||
|