Forum: Poser Python Scripting


Subject: Floating point decimals and binary representation.

structure opened this issue on Aug 24, 2021 ยท 17 posts


adp001 posted Tue, 24 August 2021 at 8:33 AM

bagginsbill posted at 8:28AM Tue, 24 August 2021 - #4425960

I cleaned up your function - it can be much simpler.

# make a new ( numbered ) copy of the original file
def uniquify( path, ext ):
    file_name = path + ext
    i = 0
    while isfile(file_name):
        i += 1
        file_name = path + "_copy_" + str(i/10) + ext
    return file_name

To make that work with Poser Versions != 12, you have to execute this first:

from __future__ import  division

If you don't you will get garbage with this function.

But, as @odf said: The better way is to use Pythons format functions to convert numbers to strings.