diff --git a/find-and-replace-graphics/findAndReplaceGraphic_transformToFit.jsx b/find-and-replace-graphics/findAndReplaceGraphic_transformToFit.jsx index ab877b8..f46f90d 100755 --- a/find-and-replace-graphics/findAndReplaceGraphic_transformToFit.jsx +++ b/find-and-replace-graphics/findAndReplaceGraphic_transformToFit.jsx @@ -1,9 +1,9 @@ ///////////////////////////////////////////////////////////////// //Copy to Object(s) v5 -- CS,CS2,CS3 -// Hacked again by Nathaniel Vaughn Kelso @ 7 June 2007 -// nvkelso@gmail.com +// Hacked again by Nathaniel Vaughn Kelso @ 7 June 2007 +// nvkelso@gmail.com // "Multiple-object-replacement" hack by Iain Henderson -// iain@addition.com.au +// iain@addition.com.au // //>=-------------------------------------- // 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 ( john@wundes.com ) 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,7 +69,7 @@ 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]; @@ -77,15 +77,15 @@ if (documents.length>0) { 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;