pK Renamer, objects renaming tool

Hi everybody!

I wrote a script for blender 2.5.3 wich allows batch renaming of objects, much like comet_rename script for maya.

I find 2.5 python API well exposed, yet I incurred in some limits. I don’t know if it’s me, or insufficient documentation, but I could not have an input field in panels if not by layout.prop() function, wich only accepts blender objects and not operators or any custom object. Or buttons, I had to create an operator for any button and use the layout.operator() function. Is there a good way to have input fields or “do it” buttons in custom panels?

Anyway, here’s my script

http://krimelia.it/images/stories/3dFiles/pk_tools_rename.zip

Looks like that:

http://i119.photobucket.com/albums/o147/Radeoff/Questions/pkRenamer.jpg

Once executed in the text editor, or added as addon in user prefeferences, it creates a voice in Objects menu.

It also can be called as console command bpy.ops.pk_tools.GUI_rename(), or, for console execution, bpy.ops.pk_tools.rename(…arguments…)

Critiques Welcome! :slight_smile:

It is not working in latest blender SVN 31546
Classes register themselves since (…) (that error is easy)

You should give a direct example, alle my approches using the console deliver errors e.g:

>>> bpy.ops.pk_tools.rename(list=“Cube”, pad=“0”, pref=“my_prefix”, suf=“my_suffix”)
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
File “C:\Users\Peter\25Blender\blenderLatest\2.53\scripts\modules\bpy\ops.py”, line 158, in call
ret = op_call(self.idname_py(), C_dict, kw)
TypeError: Converting py args to operator

And (regarding me) a concrete example (evtl. a *.blend file …)

Well, I’ll try to fix the gui for newest build asap. About the error you get from console, pad should be an int, so pad=0, without fences. Suffix argument is suff, with double F. And mainly, list should be the name of a list inside the bpy structure, containg the objects you want to rename (in blender id format).

So your example should be


bpy.types.Main.my_list = [bpy.data.objects['Cube']]
bpy.ops.pk_tools.rename(list="bpy.types.Main.my_list", pad=0, pref="my_prefix", suff="my_suffix")

I will try ‘tomorrow’ … (Opa has to look after his granddaughter today :wink: )

She is sleeping :smiley:

The menu version works (to some degree ) … but closing crashes blender?!
From the console using your example lines nothing happens but an error message
about some NoneType … an error wich occurs if one tries to use a script not as addon but directly
This is reason of ‘complaints’ by other authors other script too!