Reputation: 201
I'm a user of Blender, a 3D software.
I'm trying to run in CMD because Blender provides CLI control.
The code below works fine.
blender -b "my.blend" ^
--python-text "lowResoltion" ^
-S "scene 01" ^
-o "// output \ ##" -F PNG -f 3 ^
-S "scene 02" ^
-o "// output \ ##" -F PNG -f 5
But I want to temporarily comment out the lowResolution of the second line.
However, the above code looks like several lines, but it's a single line due to ^
, so when I use rem
or ::
it seems to be treated as telling to Blender for rem
/ ::
rather than telling to CMD.
CMD understands rem
and ::
in their native languages but sounds like a foreign language to Blender.
Is there a way to comment out the second line in this case?
The question in the link that Squashman brought is similar to my question.
However, the solution for this link, the %= =%
commenting method, still seems to be passed to Blender rather than CMD.
I think maybe the syntax of the batch file doesn't solve this problem.
When I wrap the second line with %= =%
, the blender prints ?????
and exits, as shown in the image below.
jeb's way works!
I shot a GIF as a memorial.
Notice how the resolution of two images changes with a single line of code replacement.
Because of jeb's solution, I can now easily test my code for batch rendering thousands of images using dozens of blend files.
Upvotes: 3
Views: 616
Reputation: 82307
The proposed solution with percent expansion doesn't work on the command line, because on the command line undefined variables aren't expanded to nothing, instead they are leaved unchanged.
But you can use the rarely used percent modifier syntax, %~$ANY_PATH_VARIABLE:I
.
This searches in all paths listed in the ANY_PATH_VARIABLE
for a file that is stored in the FOR-variable I
.
Sounds strange, but in your case it's simple
FOR %# in (dummy) DO @blender -b "my.blend" ^
%~$==--python-text "lowResoltion":# ^
-S "scene 01" ^
-o "// output \ ##" -F PNG -f 3 ^
-S "scene 02" ^
-o "// output \ ##" -F PNG -f 5 ^
%~$==SECOND-comment, the double colon is forbidden:# ^
%~$==THIRD-comment, but percent % is okay:#
The comment starts with the %~$==
and ends with :#
.
This searches for the for-variable %#
in variables like ==--python-text...
or ==SECOND-comment, the ...
.
These variables can't exist, because they begin with equal signs.
Therefor the result of the expansion is always nothing, because dummy
can't be a file in any directory of an undefined variable.
There is only a small problem, if you are still trying to use this in windows XP, there the variable name must not contain delimiters (space, comma, equal sign).
Upvotes: 3