Bonjour à tous,

J'utilise PythonTex pour résoudre un problème et obtenir des valeurs numériques que je peux réutiliser dans un fichier LaTeX. Une figure TIKZ est paramétrée et dépend des paramètres calculés par la routine Python (via PythonTeX).

J'arrive parfaitement à générer toutes mes variables mais lorsque je les affecte (newcommand, def, xdef, ...) il m'est impossible de les comparer avec un paramètre afin de déterminer si la condition est validée (elle est toujours invalide).

Pourtant si j'affiche la variable obtenue par pythontex, je l'affiche correctement mais il m'est impossible de faire un test ifthenelse valide. J'utilise les packages ifthen et pythontex principalement.

Quelqu'un a-t-il une idée de comment faire passer le test ifthenelse ?

Voici le morceau de code (fichier TeX secondaire appelé par un input dans le fichier principal).

En vous remerciant par avance et bonne journée,

S. Thibaud

Code :Sélectionner tout -Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 
\newcommand{\CondNodeOne}{L}% 'E'=Encastrement et 'L'=Pivot
\newcommand{\CondNodeThree}{E}% 'L'=Appui et 'E'=Guidage
\def\LoadCase{\pys{!{Cond[0]}}}
\def\Encastrement{'E'}
\def\LoadTypeNodeTwoX{Dimp}% Noeud2 selon x 'Dimp'=dep imposé, 'Fimp'=effort imp, 'L' : Libre
\def\LoadTypeNodeTwoY{Dimp}% Noeud2 selon y
\def\LoadTypeNodeTwoZ{Dimp}% Noeud2 autour de z
\def\LoadTypeNodeThreeX{Dimp}% Noeud3 selon x
 
\def\dtwox{\py{Param[0]}}
\def\ftwox{\py{Param[1]}}
\def\dtwoy{-1}
\def\ftwoy{2500}
\def\dtwoz{-0.1}
\def\ftwoz{5}
\def\dthreex{0.2}
\def\fthreex{-1000}
\def\lgthone{250}
\def\lgthtwo{350}
\def\lgthh{50}
 
\pys{!{Cond[0]}}
\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}
%\draw[help lines,line width=0.6pt](0,0) grid (16,8);% Aide pour placer texte sur la figure
%\draw[help lines,step=0.1](0,0) grid (16,8);% Aide pour placer texte sur la figure
%\node[anchor=south west,inner sep=0pt] (PV) at (0,0)
%    {\includegraphics[width=.4\textwidth]{PanneauModele.pdf}};
%\draw (11cm,6.2cm) node[above] {Définition des sections des profilés (en \milli\meter)};
\draw[thick,->](1cm,1cm)--(1cm,3cm);
\draw[thick,->](1cm,1cm)--(3cm,1cm);
\draw[thin,dashed](1cm,1cm)--(11cm,1cm);
\draw[thin,<->](5cm,1cm)--(5cm,3.3cm);
 
% Noeud 1
 
\draw[line width=1mm](1cm,1cm)--(5cm,3.5cm);
\draw[line width=1mm](5cm,3.5cm)--(11cm,1cm);
% Encastrement
\ifthenelse{\equal{\pys{!{Cond[0]}}}{L}}{
%\ifthenelse{\equal{\CondNodeOne}{L}}{
\foreach \k in {0,2,...,8}
{\draw[very thick](0.5cm,0.6cm+\k mm)--(0.1cm,0.4cm+\k mm);}
\draw[very thick](0.5cm,0.6cm)--(0.5cm,1.4cm);
\draw[very thick](0.5cm,1cm)--(1cm,1cm);
\draw[fill=white,very thick](1cm,1cm) circle (3pt);
 
}{
\filldraw[fill=black, draw=black]
    (1cm,1cm) -- (1cm,1.3cm) arc (90:30:3mm) -- (1cm,1cm);% Encastrement à l'origine
\foreach \k in {0,2,...,8}
{\draw[very thick](1cm,0.6cm+\k mm)--(0.6cm,0.4cm+\k mm);}
\draw[very thick](1cm,0.6cm)--(1cm,1.4cm);
 
 
};
 
 
 
 
\draw(1cm,3cm) node[above] {$\vec{y}$};
\draw(3cm,2.4cm) node[above] {$L_1$};
\draw(3.4cm,2.3cm) node[below] {\ding{172}};
\draw(7.6cm,2.3cm) node[below] {\ding{173}};
\draw(8cm,2.4cm) node[above] {$L_2$};
\draw(5cm,2.25cm) node[right] {$h=\lgthh\,\si{\milli\meter}$};
\draw(3.1cm,1cm) node[above] {$\vec{x}$};
\draw(1.2cm,0.9cm) node[below] {1};
\draw(5.2cm,3.5cm) node[above] {2};
\draw(11cm,1.2cm) node[above] {3};
\filldraw[fill=black, draw=black]
    (5cm,3.5cm) -- (5cm,3.3cm) arc (-90:-20:2mm) -- (5cm,3.5cm);
\filldraw[fill=black, draw=black]
    (5cm,3.5cm) -- (5cm,3.3cm) arc (-90:-150:2mm) -- (5cm,3.5cm);
 
% Guidage au noeud 3
\ifthenelse{\equal{\CondNodeThree}{E}}{
\draw[fill=white,thick](10.7cm,0.4cm) circle (2.5pt);
\draw[fill=white,thick](11.3cm,0.4cm) circle (2.5pt);
\draw[very thick](11cm,1cm)--(11cm,0.5cm);
\draw[very thick](10.6cm,0.5cm)--(11.4cm,0.5cm);
\draw[very thick](10.6cm,0.3cm)--(11.4cm,0.3cm);
\foreach \k in {0,2,...,8}
{\draw[very thick](10.6cm+\k mm,0.3cm)--(10.8cm+\k mm,0cm);}
\filldraw[fill=black, draw=black]
    (11cm,1cm) -- (11cm,0.8cm) arc (-90:-210:2mm) -- (11cm,1cm);% Encastrement au noeud 3
}{};
 
% Appui mobile au noeud 3
\ifthenelse{\equal{\CondNodeThree}{L}}{
\draw[fill=white,thick](10.85cm,0.5cm) circle (2.5pt);
\draw[fill=white,thick](11.15cm,0.5cm) circle (2.5pt);
\filldraw[fill=white, draw=black,thick]
    (10.75cm,0.6cm) -- (11.25cm,0.6cm) -- (11cm,1cm) -- (10.75cm,0.6cm);% Triangle appui
\draw[thick](10.6cm,0.4cm)--(11.4cm,0.4cm);
\foreach \k in {0,2,...,8}
{\draw[very thick](10.6cm+\k mm,0.4cm)--(10.8cm+\k mm,0.1cm);}
}{};
% Vecteurs déplacements ou efforts
%% Noeud 2 direction x
%\ifthenelse{\equal{\py{Cond[3]}}{Dimp}}{
\ifthenelse{\equal{\LoadTypeNodeTwoX}{Dimp}}{
\draw[very thick,->](5.1cm,3.5cm)--(6.1cm,3.5cm);%F2x ou d2x
%\draw (6.1cm,3.5cm) node[right] {$U_{2x}=\num{\dtwox}\,\si{\milli\metre}$};
\draw (6.1cm,3.5cm) node[right] {$U_{2x}=\dtwox\,\si{\milli\metre}$};
}{};
\ifthenelse{\equal{\LoadTypeNodeTwoX}{Fimp}}{
\draw[very thick,->](5.1cm,3.5cm)--(6.1cm,3.5cm);%F2x ou d2x
\draw (6.1cm,3.5cm) node[right] {$F_{2x}=\ftwox\,\si{\newton}$};
}{};
%% Noeud 2 direction y
\ifthenelse{\equal{\LoadTypeNodeTwoY}{Dimp}}{
\draw[very thick,->](5cm,3.6cm)--(5cm,4.6cm);%d2y
\draw (5cm,4.6cm) node[above] {$U_{2y}=\dtwoy\,\si{\milli\metre}$};
}{};
\ifthenelse{\equal{\LoadTypeNodeTwoY}{Fimp}}{
\draw[very thick,->](5cm,3.6cm)--(5cm,4.6cm);%F2y
\draw (5cm,4.6cm) node[above] {$F_{2y}=\ftwoy\,\si{\newton}$};
}{};
%% Noeud 2 direction z
\ifthenelse{\equal{\LoadTypeNodeTwoZ}{Dimp}}{
\draw[very thick,->](4.9cm,4cm) arc (92:200:0.5cm);%Theta2z
\draw (4.4cm,3.7cm) node[left] {$\theta_{2y}=\num{\dtwoz}\,\si{\radian}$};
}{};
\ifthenelse{\equal{\LoadTypeNodeTwoZ}{Fimp}}{
\draw[very thick,->](4.9cm,4cm) arc (92:200:0.5cm);%M2z
\draw (4.4cm,3.7cm) node[left] {$M_{2z}=\num{\ftwoz}\,\si{\newton\milli\meter}$};
}{};
%% Noeud 3 direction x
\ifthenelse{\equal{\LoadTypeNodeThreeX}{Dimp}}{
\draw[very thick,->](11.1cm,1cm)--(12.1cm,1cm);%F3x ou d3x
\draw (12.1cm,1cm) node[right] {$U_{3x}=\num{\dthreex}\,\si{\milli\meter}$};
}{};
\ifthenelse{\equal{\LoadTypeNodeThreeX}{Fimp}}{
\draw[very thick,->](11.1cm,1cm)--(12.1cm,1cm);%F3x ou d3x
\draw (12.1cm,1cm) node[right] {$F_{3x}=\num{\fthreex}\,\si{\newton}$};
}{};
 
 
 
 
%\filldraw[color=gray!20,draw=black](10cm,3cm)--(12cm,3cm)--(12cm,5cm)--(10cm,5cm)--cycle;
%\filldraw[color=white,draw=black](10.1cm,3.1cm)--(11.9cm,3.1cm)--(11.9cm,4.9cm)--(10.1cm,4.9cm)--cycle;
 
\draw[fill=gray,thick](9.5cm,4.2cm) circle (0.6cm);
\draw (8.5cm,5.5cm) node[right] {Sections circulaires - $D_{\sec}=9\,\si{\milli\metre}$};
\draw(10.5cm,4.8cm) node[right] {$S=\frac{\pi\cdot D_{\textrm{sec}}^2}{4}=63,6173\,\si{\milli\meter^{2}}$};
\draw(10.5cm,4.2cm) node[right] {$I=\frac{\pi\cdot D_{\textrm{sec}}^4}{64}=322,0623\,\si{\milli\meter^{4}}$};
\draw(10.5cm,3.6cm) node[right] {$k=\frac{6}{7}=0,8571$};
\draw(12cm,3cm) node[below] {$L_1=\lgthone\,\si{\milli\metre}$};
\draw(12cm,2.5cm) node[below] {$L_2=\lgthtwo\,\si{\milli\metre}$};
\draw(6cm,0.8cm) node[below] {$E=70000\,\si{\mega\pascal}$ - $\nu=0,28$};
 
 
\end{tikzpicture}
\end{center}
\end{figure}