Tag suite: Maintenant un script qui trace un rectangle autour de l'objet comme le ferait l'outil de sélection (V). exemple 1: exemple 2: PS je peux vous faire parvenir un script (par mail) qui sur Illustrator supprime les numéros de ligne 01. 02.etc pour une récupération plus rapide par copier coller. // JavaScript Document for Illustrator // Finds the tags of name "BBAccumRotation" associated with the selected art item, // angle to the vertical direction // of Sily V modif elleere #target illustrator function getAngle(sel){ var sel, mes, nb, angle, angleRad, angleDeg; sel = activeDocument.selection[0]; mes = "Create a new Tag with the name BBAccumRotation y/n ?"; nb = sel.tags.length; //alert(nb) if (!nb) { if (!confirm (mes,false,"De Elleere")){ return undefined; } var BBAccumRotationTAG = sel.tags.add(); BBAccumRotationTAG.name = "BBAccumRotation"; BBAccumRotationTAG.value = 0; nb = 1; } do { if (sel.tags[nb-1].name == "BBAccumRotation" ) { angle = sel.tags[nb-1].value*1; //in radians angleRad = angle.toFixed(5).replace(/.00000/,"");; angleDeg = angle*180/Math.PI; //in degrees angleDeg = angleDeg.toFixed(2).replace(/.00/,""); alert("méthode tags\nangleRad = "+angleRad+" rd\nangleDeg = "+angleDeg+"°"); nb = 0 } else{nb--;} } while (nb); return angle; } //--------------- var doc = activeDocument; if (selection.length) { var sel, a, pos, Bounds, w, h ,x, y, cadre, newpos, prop0, prop, p0; sel = activeDocument.selection[0]; a = getAngle(sel)*180/Math.PI; if (!isNaN(a)) { pos = sel.position; sel.rotate(-a); Bounds = sel.geometricBounds; w = Bounds[2]-Bounds[0]; h = Bounds[1]-Bounds[3]; x = Bounds[0]; y = Bounds[1]; cadre = doc.pathItems.rectangle(y,x,w,h); cadre.filled = false; cadre.stroked = true; cadre.strokeWidth = 1; sel.rotate(a); cadre.rotate(a); newpos = sel.position; sel.position = pos; cadre.translate(pos[0]-newpos[0],pos[1]-newpos[1]); //} // propriétés du cadre rectangulaire créé (De Sily + elleere) prop0 = {w:w, h:h, r:a}; alert(getArrondi(prop0.r,2)+"°\n"+getArrondi(prop0.w,2)+"\n"+getArrondi(prop0.h,2),"Tag"); p0 = doc.textFrames.pointText(pos); p0.contents = "Tag\r"+getArrondi(prop0.r,2)+"°\n"+getArrondi(prop0.w,2)+"\n"+getArrondi(prop0.h,2); p0.translate(0,-h*2); // propriétés du cadre rectangulaire créé (De Loïc) prop = getPathItemProperties (cadre); alert(getArrondi(prop.r,2)+"°\n"+getArrondi(prop.w,2)+"\n"+getArrondi(prop.h,2),"Loïc"); p0 = doc.textFrames.pointText(pos); p0.contents = "Loïc\r"+getArrondi(prop.r,2)+"°\n"+getArrondi(prop.w,2)+"\n"+getArrondi(prop.h,2); p0.translate(60,-h*2); //cadre.remove(); } } //--------------- function getPathItemProperties ( pathitem ) { var x1, x2, y1, y2, x4,y4, w2,w, h2,h, angleH, cos, factor, angle; while ( pathitem.typename != "PathItem" ) { pathitem = pathitem.pageItems[0]; } x1 = pathitem.pathPoints[0].anchor[0]; y1 = pathitem.pathPoints[0].anchor[1]; x2 = pathitem.pathPoints[1].anchor[0]; y2 = pathitem.pathPoints[1].anchor[1]; x4 = pathitem.pathPoints[3].anchor[0]; y4 = pathitem.pathPoints[3].anchor[1]; w2 = Math.pow ( Math.abs ( x2 - x1 ), 2 ) + Math.pow ( Math.abs ( y2 - y1 ), 2 ); w = Math.sqrt (w2); h2 = Math.pow ( Math.abs ( x4 - x1 ), 2 ) + Math.pow ( Math.abs ( y4 - y1 ), 2 ); h = Math.sqrt (h2); angleH = Math.abs ( y2 - y1 ); cos = angleH/w; factor = ( y2 > y1 )? -1 : 1; angle = factor * ( Math.acos (cos)*180/Math.PI ); return { w:h, h:w, r:angle} // inversio h et w } //--------------- function getArrondi(nb,N) { //arrondi nb a N chiffres apres la virgule return Math.round(Math.pow(10,N)*nb)/Math.pow(10,N); } //---------------
... View more