From 8da041a311f52f0232010132c137218f9dda33f8 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Mon, 11 Apr 2011 06:10:07 +0000 Subject: Rigify: fixed broken ik/fk snapping (api changes). --- rigify/utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'rigify/utils.py') diff --git a/rigify/utils.py b/rigify/utils.py index f7a33c22..193a2779 100644 --- a/rigify/utils.py +++ b/rigify/utils.py @@ -18,7 +18,8 @@ import bpy import imp -from random import randint +import random +import time from mathutils import Vector from math import ceil, floor from rna_prop_ui import rna_idprop_ui_prop_get @@ -497,10 +498,16 @@ def write_metarig(obj, layers=False, func_name="create_sample"): return "\n".join(code) -def random_string(length): +def random_id(length = 8): + """ Generates a random alphanumeric id string. + """ + tlength = int(length / 2) + rlength = int(length / 2) + int(length % 2) + chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] text = "" - for i in range(0, length): - text += chars[randint(0, 35)] + for i in range(0, rlength): + text += random.choice(chars) + text += str(hex(int(time.time())))[2:][-tlength:].rjust(tlength, '0')[::-1] return text -- cgit v1.2.3