[Closed] Exporting custom values to a text file.
Ok, I tried renaming the modifier, and attribute, and put in,
f = createFile “c:\attribute_name.txt”
format “float01 = %” $sphere01.modifiers[‘custom01’].float01 to:f
flush f
close f
and the error still is,
<File:c:\attribute_name.txt>
– Error occurred in anonymous codeblock; filename: ; position: 70
– Type error: Modifier array index must be number or name, got: undefined
OK
OK
and the file still is blank. I also made sure to delete the file, before I evaluated btw.
You need to put in the actual name of your modifier you’re trying to access, not ‘custom01’. Alternately, since the mod stack index is 1-based starting at the top of the stack, if it’s always in the same place in the mod stack, you could use the index of that modifier, like
$sphere01.modifiers[1].float01
In this case, “float01” should be replaced by whatever name you’ve given the value you’re trying to retrieve from the modifier at the top of the stack (modifiers[1])
Also, you’re probably going to want your formatted string to include the “
” escape character;
format "float01: %
"
This will add a new line, otherwise it’s going to be hard to decipher, as it will be all on the same line without any breaks.
edit: and afaik, it’s not necessary to delete your txt file before running the script. I’ve got a log file that gets “created” every day, and I’ve never had to delete it before it gets created in the script. Having it open, well that may be another matter.
^^ Yaaay! thanks alot, that works like a charm My spinner was called float01 btw. Here is what I put,
f = createFile “c:\attribute_name.txt”
format “float01: %
” $sphere01.modifiers[1].float01 to:f
flush f
close f
Listener says,
OK<File:c:\attribute_name.txt>
OK
OK
OK
File says,
float01: 0.00
and I say, yaaaaay handiklap! Thanks everyone!
Oh and for anyone else needing to know how to output more than one value, you can type this for 2 values, one for the radius value and one for the float01 value
f = createFile “c:\attribute_name.txt”
format “sphereRadius = %, float01: %
” $sphere01.radius $sphere01.modifiers[1].float01 to:f
flush f
close f
and the file will say this,
sphereRadius: 12.671, float01: 8.1
(I changed the values to make sure they were working) Ok thanks again!