This is a follow-up to How to specify tikz drawing size without scaling it. The advice given there works, but the picture still doesn't have a fixed size. In some way, the height depends on how the figure is loaded. I suspect that the problem has nothing to do with TikZ, and that the problem lies in the environment's definition.
The MWE below defines the intfig environment, which takes a file name (without the .tikz suffix), and the height that the figure should have. In the MWE, the body of the environment is ignored. The environment is defined to look for the given .tikz file. If the file exists, it is loaded; if it does not exist, then a box is displayed with a "not available" message. If the file doesn't exist and is not loaded then the figure has one height; if the file is available, then the figure seems to be one line of text taller than expected.
\documentclass[10pt]{article} \ExplSyntaxOn \str_new:N \l_intfig_figname_str \dim_new:N \l_intfig_height_dim \cs_generate_variant:Nn \file_if_exist:nTF {V} \cs_generate_variant:Nn \file_input:n {V} \NewDocumentEnvironment{intfig} { > { \SplitArgument { 1 } { , } } m!o } { \group_begin: \intfig_manargs #1 }{ % Post environment commands. \str_set_eq:NN \l_intfig_tikzfile_str \l_intfig_figname_str \str_put_right:Nn \l_intfig_tikzfile_str { .tikz } \file_if_exist:VTF \l_intfig_tikzfile_str { \file_input:V \l_intfig_tikzfile_str } { \begin{tikzpicture} \useasboundingbox (0pt,0pt) rectangle (\textwidth,\l_intfig_height_dim); \draw[dashed] (0pt,0pt) rectangle ( \textwidth,\l_intfig_height_dim); \node at (\textwidth / 2,\l_intfig_height_dim / 2) {The\ drawing\ is\ not\ available\ to\ load.}; \draw (5pt,5pt) rectangle ( \textwidth - 5,\l_intfig_height_dim - 5); \end{tikzpicture} } \group_end: } \NewDocumentCommand{\intfig_manargs}{ m m } { \str_set:Nn \l_intfig_figname_str { #1 } \dim_set:Nn \l_intfig_height_dim { #2 } } \ExplSyntaxOff \usepackage{tikz} \begin{document} Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. Random text to fill out the page. \begin{intfig}{bezier,200bp} \end{intfig} Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. Some text after the figure. \end{document} Compile the above without the bezier.tikz file available, and you get a figure of one size. Now compile it again, with the text below saved as bezier.tikz and you get the correct figure, but the figure is taller than expected.
\begin{tikzpicture}[yscale=-1] \useasboundingbox (0bp,0bp) rectangle (343.71109bp,200bp); \draw[line width=4bp] (63.56039999999999bp, 27.39158999999995bp) -- (23.560399999999987bp, 57.39158999999995bp) -- (96.56039999999999bp, 121.39158999999995bp) -- (199.5604bp, 79.39158999999995bp) ; \draw[line width=4bp] (63.56039999999999bp, 27.39158999999995bp) .. controls (23.560399999999987bp, 57.39158999999995bp) and (96.56039999999999bp, 121.39158999999995bp) .. (199.5604bp, 79.39158999999995bp); \fill (63.56039999999999bp,27.39158999999995bp) ellipse [x radius=3bp,y radius =3bp]; \fill (23.560399999999987bp,57.39158999999995bp) ellipse [x radius=3bp,y radius =3bp]; \fill (96.56039999999999bp,121.39158999999995bp) ellipse [x radius=3bp,y radius =3bp]; \fill (199.5604bp,79.39158999999995bp) ellipse [x radius=3bp,y radius =3bp]; \end{tikzpicture} No part of the figure extends outside the bounding box, and the same bounding box is used in both cases (tikz file present or not). And yes, \textwidth = 345 pt, which is equal to 343.711 bp, although I don't see how the width would have any effect.
If the environment is eliminated entirely, and \begin{intfig} \end{intfig} is replaced with either the "not available" figure or the contents of bezier.tikz, then the two figures take exactly the same amount of space on the page, as expected.
\end{intfig}%