You can redefine and introduce a switch if you already have plenty of code instances of the same environment. So, expanding on Jasper Habicht's comment, you could do the following:
- create a switch
- redefine the environment in question
- in the redefined environment, enclose a regular environment within an if clause (based on the switch), so it depends on that switch.
LaTeX already has a built-in mechanic to create custom if's. Have a look at this post.
Since you have mentioned tikz in your question, I made an example upon tikzpicture. Here is how to put everything together. Every time you use \tikzpicsfalse you are going to turn off tikz, whereas \tikzpicstrue is going to bring it back.
\documentclass{article} \usepackage{tikz} \newif\iftikzpics \tikzpicsfalse % \tikzpicstrue to turn pictures on \NewEnvironmentCopy{oldtikzpicture}{tikzpicture} \RenewDocumentEnvironment{tikzpicture}{O{}+b}{% \iftikzpics \begin{oldtikzpicture}[#1] #2 \end{oldtikzpicture}\fi}{} \begin{document} X \begin{tikzpicture} \node {A}; \end{tikzpicture} \begin{tikzpicture}[ scale=2, baseline, every node/.style = {draw}, ] \node [transform shape] {B}; \end{tikzpicture} \end{document}
\RenewDocumentEnvironment{tikzpicture}{+b}{\iffalse#1\fi}{}. But maybe you could provide a use case that better shows what you're after? Do you want to keep the place, for example?externallibrary doesn't work for the particular pictures in question. (Some it works fine for; some not.) You could also put the pictures' code in separate files and load it with a macro you can then easily redefine. E.g.\newcommand* \mypicloader[1]{\input{#1}and\renewcommand* \mypicloader[1]{}which lets you exempt sometikzpictures if you want to.