hieght=9.25; width=12.125/2; sPn=.375; spineText="3/8\""; templateMarks(hieght,width,sPn,spineText) function templateMarks(hieght,width,spineWidth,spineText){ app.activeDocument.zeroPoint = [12,7.75]; myDocument=app.activeDocument var mark1=app.activeDocument.pageItems.item("topLeftTicMark"); var mark2=app.activeDocument.pageItems.item("bottomLeftTicMark"); var mark3=app.activeDocument.pageItems.item("topOutsideSpine"); var mark4=app.activeDocument.pageItems.item("bottomOutsideSpine"); var mark5=app.activeDocument.pageItems.item("topRightTicMark"); var mark6=app.activeDocument.pageItems.item("bottomRightTicMark"); var mark7=app.activeDocument.pageItems.item("topInsideSpine"); var mark8=app.activeDocument.pageItems.item("bottomInsideSpine"); var mark9=app.activeDocument.pageItems.item("SpineSzText"); var templateItemsArray=[mark1,mark2,mark3,mark4,mark5,mark6,mark7,mark8,mark9]; //spineCenter=mark3.visibleBounds[1]-mark3.visibleBounds[3]; spineCenter=mark3.geometricBounds[1]-mark3.geometricBounds[3]; spineCenterInside=mark7.visibleBounds[1]-mark7.visibleBounds[3]; spineMarkHeight=mark4.visibleBounds[0]-mark4.visibleBounds[2]; spineTextWidth=mark9.visibleBounds[1]-mark9.visibleBounds[3]; spineTextHieght=mark9.visibleBounds[0]-mark9.visibleBounds[2]; horizontalGuides=[]; verticalGuides=[]; var templatePieces={ topLeftTicMark:{ item: mark1, movement: [-width,-hieght/2] }, bottomLeftTicMark:{ item: mark2, movement: [-width,hieght/2] }, topRightTicMark:{ item: mark3, movement: [width,-hieght/2] }, bottomRightTicMark:{ item: mark4, movement: [width,hieght/2] }, topOutsideSpine:{ item: mark5, movement: [spineCenter/2,-hieght/2-spineMarkHeight] }, bottomOutsideSpine:{ item: mark6, movement: [spineCenter/2,hieght/2-spineMarkHeight+.75] }, topInsideSpine:{ item: mark7, movement: [spineCenterInside/2,-hieght/2-spineMarkHeight] }, bottomInsideSpine:{ item: mark8, movement: [spineCenterInside/2,hieght/2-spineMarkHeight+.75] }, SpineSzText:{ item: mark9, movement: [spineTextWidth/2,hieght/2-spineTextHieght+.75] } } if(spineWidth<=.75){ templateItemsArray.splice(6,2); mark7.remove() mark8.remove() } countInside=0; for (var i = 0; i < templateItemsArray.length; i++) { try{ templateItemsArray.move(undefined,templatePieces[templateItemsArray.label.toString()]["movement"]); if(templateItemsArray.label.toString().indexOf("OutsideSpine")!=-1){ var spineBounds=templateItemsArray.geometricBounds; ///after the spine marks are moved change the spine size templateItemsArray.geometricBounds=[spineBounds[0],mark1.geometricBounds[3]+width-spineWidth/2,spineBounds[2],mark1.geometricBounds[3]+width+spineWidth/2]; } if(templateItemsArray.label.toString().indexOf("InsideSpine")!=-1&&spineWidth>.75){ countInside++ var spineBounds=templateItemsArray.geometricBounds; ///after the spine marks are moved change the inside spine marks templateItemsArray.geometricBounds=[spineBounds[0],mark1.geometricBounds[3]+width-spineWidth/2+.375,spineBounds[2],mark1.geometricBounds[3]+width+spineWidth/2-.375];///change size if(countInside==1){ myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(templateItemsArray.geometricBounds[1])}); } else{ myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(templateItemsArray.geometricBounds[3])}); } } } catch(err){ $.writeln(err) } } myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(0)});///Set vertical center of spine guide myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark1.geometricBounds[3])}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.horizontal, location:(mark1.geometricBounds[2])}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark1.geometricBounds[3]-.75)}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.horizontal, location:(mark1.geometricBounds[2]-.75)}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark6.geometricBounds[1])}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.horizontal, location:(mark6.geometricBounds[0])}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark6.geometricBounds[1]+.75)}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.horizontal, location:(mark6.geometricBounds[0]+.75)}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark3.geometricBounds[1])}); myDocument.guides.add(myDocument.layers[0],{orientation:HorizontalOrVertical.vertical, location:(mark3.geometricBounds[3])}); ///fill the spine text with the xml data about the spine size in fraction form/// mark9.contents=spineText+"\nSpine Size"; } T This works when run from the toolkit but it errors saying that the object spineCenter is not valid. I have not been able to figure out why the difference.
... View more