scripting indesign "auto grow"

wanya74

Membre confirmé
19 Août 2003
20
0
Bonjour,

voici un bout de code qu'il suffit de copier et de coller sous applescript editor pour se rendre compte que la command "auto grow" ne fonctionne pas...

si qq'un a une soluce...?
merci d'avance

------------------------------------------------------------------------
set varstring to "contenu cellule 1"
set i to 0
tell application "InDesign 2.0.2"
set mystartColumnColor to make color with properties {name:"mystartColumnColor", color value:{50, 0, 50, 0}}
set mydocument to make document
tell mydocument
set myHighColor to make color with properties {name:" myHighColor", color value:{50, 0, 50, 0}}
set myLowColor to make color with properties {name:" myHighColor", color value:{25, 0, 25, 0}}
tell page (count of pages)
repeat 5 times
set i to i + 1
if i is equal to 5 then
set varstring to varstring & "contenu cellule 1" & tab & "contenu" & tab & "contenu" & tab & "contenu"
else
set varstring to varstring & tab & "contenu cellule 2" & tab & "contenu cellule 3" & tab & "contenu cellule 4" & return
end if
end repeat
set myTextFrameTableau to make text frame with properties ¬
{geometric bounds:{15, 15, 100, 200}, contents:varstring}
tell text style range 1 of parent of myTextFrameTableau
set mytableau to make table of myTextFrameTableau

tell mytableau
--bord tableau
set left border stroke weight of mytableau to 0
set right border stroke weight of mytableau to 0
set top border stroke weight of mytableau to 0.3
set bottom border stroke weight of mytableau to 0.3

--colonnes
set start column stroke count of mytableau to 1
set end column stroke count of mytableau to 1
set start column stroke weight of mytableau to 0
set end column stroke weight of mytableau to 0
--set column 2 to auto grow
--lignes
set skip first alternating fill rows of mytableau to 0
set start row stroke count of mytableau to 1
set start row fill color of mytableau to myHighColor
set end row stroke count of mytableau to 1
set start row stroke weight of mytableau to 0 --0.1
set end row stroke weight of mytableau to 0 --0.1

set end row fill color of mytableau to myHighColor

tell column 1
set auto grow of column 1 of mytableau to true
end tell


set x to count of rows of mytableau

repeat with T from 1 to x
set VARX to (T mod 2)
if VARX is equal to 1 then
set fill color of row T of mytableau to myHighColor
else
set fill color of row T of mytableau to myLowColor
end if
end repeat

move myTextFrameTableau to {15, 15}
end tell
end tell
end tell
end tell
end tell
------------------------------------------------------------------------
 
Bonjour,

Voilà un "modèle" à ajuster à tes besoins.

<font class="small">Code:</font><hr /><pre>
tell table 1 of text frame 1
set auto grow of columns to true
set auto grow of rows to true
set width of it to largeur_du_bloc_texte *
set height of it to hauteur_du_bloc_texte *
end tell
</pre><hr />

*Fais attention à l'épaisseur des filets de ligne et de colonnes.

Si tu as besoin de plus d'explications, fais-moi signe.
 
Merci,

Ton bout de prog ne genere pas d'erreur mais l'auto grow ne fonctinne toujours pas..?!?
par contre la command width fonctionne...

peut etre une explication....?
 
Je crois qu'il y a un problème sur la compréhension du terme "auto grow".

Est-ce que ça veut dire :

• Quand j'élargis la colonne, j'élargis le tableau entier ?

ou

• Quand je met un texte plus grand que la colonne, elle s'élargit automatiquement

ou autre chose ?
confused.gif
 
voici le script entier si sa peut t'aider :

-----------------------------------------------------------------
set varstring to "contenu cellule 1"
set i to 0
tell application "InDesign 2.0.2"
set mystartColumnColor to make color with properties {name:"mystartColumnColor", color value:{50, 0, 50, 0}}
set mydocument to make document
tell mydocument
set myHighColor to make color with properties {name:" myHighColor", color value:{50, 0, 50, 0}}
set myLowColor to make color with properties {name:" myHighColor", color value:{25, 0, 25, 0}}
tell page (count of pages)
repeat 5 times
set i to i + 1
if i is equal to 5 then
set varstring to varstring &amp; "contenu cellule 1" &amp; tab &amp; "contenu" &amp; tab &amp; "contenu" &amp; tab &amp; "contenu"
else
set varstring to varstring &amp; tab &amp; "contenu cellule 2" &amp; tab &amp; "contenu cellule 3" &amp; tab &amp; "contenu cellule 4" &amp; return
end if
end repeat
set myTextFrameTableau to make text frame with properties ¬
{geometric bounds:{15, 15, 100, 200}, contents:varstring}
tell text style range 1 of parent of myTextFrameTableau
set mytableau to make table of myTextFrameTableau

tell mytableau

--bord tableau
set left border stroke weight of mytableau to 0
set right border stroke weight of mytableau to 0
set top border stroke weight of mytableau to 0.3
set bottom border stroke weight of mytableau to 0.3

--colonnes
set start column stroke count of mytableau to 1
set end column stroke count of mytableau to 1
set start column stroke weight of mytableau to 0
set end column stroke weight of mytableau to 0
--set column 2 to auto grow
--lignes
set skip first alternating fill rows of mytableau to 0
set start row stroke count of mytableau to 1
set start row fill color of mytableau to myHighColor
set end row stroke count of mytableau to 1
set start row stroke weight of mytableau to 0 --0.1
set end row stroke weight of mytableau to 0 --0.1

set end row fill color of mytableau to myHighColor


-----------------&gt; ici l'auto grow &lt;-------------------------
tell columns
set auto grow of columns to true
set auto grow of rows to true
-- set width of it to 40
end tell

(*
tell table 1 of text frame 1
set auto grow of columns to true
set auto grow of rows to true
set width of it to largeur_du_bloc_texte *
set height of it to hauteur_du_bloc_texte *
end tell
*)
set x to count of rows of mytableau

repeat with T from 1 to x
set VARX to (T mod 2)
if VARX is equal to 1 then
set fill color of row T of mytableau to myHighColor
else
set fill color of row T of mytableau to myLowColor
end if
end repeat

move myTextFrameTableau to {15, 15}
end tell
end tell
end tell
end tell
end tell
--------------------------------------------------------------------

Merci
 
C'est un peu complexe à expliquer.
Bien que 'auto grow' puisse s'appliquer à une colonne ou à une ligne, ce n'est qu'une propriété de cellule.
Très exactement, c'est la faculté d'une cellule à adapter sa hauteur à son contenu.
Pouvoir appliquer 'auto grow' à une colonne ou une ligne est une "facilité" qui nous évite un code du genre :
'set auto grow of every cell of every row of column 1 to true'.
A ma connaissance, il n'y a pas de possibilité d'ajuster la largeur d'une colonne à son contenu.
Sauf à la main.

Est-ce un oubli de la part des développeurs ? Verra-t-on dans la version 3 un menu "ajuster les colonnes aux contenu des cellules" ?
Il faudrait pour cela qu'on puisse, comme pour les lignes, jouer sur la 'largeur mini' et la 'largeur maxi' d'une colonne.

Ceci dit, il manquait une commande essentielle à mon bout de code (elle s'est perdue dans le copier-coller):
'set minimum height of rows to 2'
C'est grâce à ça qu'une ligne de tableau peut prendre la hauteur d'une seule ligne de texte.

Voici le script, légèrement nettoyé.
Variez les valeurs de hauteur et largeur du tableau. Vous verrez divers comportements.

Bon scriptage !

-------------------------

tell application "InDesign 2.0.2"
activate
set mydocument to make document
tell mydocument
set myHighColor to make color with properties {name:" myHighColor", color value:{50, 0, 50, 0}}
set myLowColor to make color with properties {name:" myLowColor", color value:{25, 0, 25, 0}}
tell page (count of pages)
set varstring to "contenu 1 contenu cellule 2 contenu cellule 3 cellule 3 contenu cellule 4
contenu 1 contenu cellule 2 cellule 2 contenu cellule 3 contenu cellule 4
contenu 1 contenu contenu cellule 3 contenu cellule 4
contenu 1 contenu cellule 2 cellule 2 contenu cellule 3 contenu cellule 4
contenu 1 contenu contenu contenu"
set myTextFrameTableau to make text frame with properties {geometric bounds:{15, 15, 100, 200}, contents:varstring}

set mytableau to make table of myTextFrameTableau
tell mytableau

--bordures tableau
set left border stroke weight of mytableau to 0
set right border stroke weight of mytableau to 0
set top border stroke weight of mytableau to 0.3
set bottom border stroke weight of mytableau to 0.3

--bordures colonnes
set start column stroke count of mytableau to 1
set end column stroke count of mytableau to 1
set start column stroke weight of mytableau to 0
set end column stroke weight of mytableau to 0

--bordures lignes
set start row stroke count of mytableau to 1
set end row stroke count of mytableau to 1
set start row stroke weight of mytableau to 0
set end row stroke weight of mytableau to 0

-- couleurs lignes
set skip first alternating fill rows of mytableau to 0
set start row fill count to 1
set start row fill color to myHighColor
set start row fill tint to 100
set skip last alternating fill rows of mytableau to 0
set end row fill count to 1
set end row fill color to myLowColor
set end row fill tint to 100

--auto grow
set width of it to 85
set height of it to 60
set auto grow of cells to true
set minimum height of rows to 2

end tell
end tell
end tell
end tell