0

Problem description


I've got a simple script in Text Editor

enter image description here

And want to get the function defined in it be able to execute from Python Console.
Old Blender Cookie tutorial says that all I have to do is write in console:

>>> from rename import BatchRename
>>> BatchRename('Monkey')

But I've got a Traceback message enter image description here

I looked through a lot of artitcles but only this one was helpfull.
And the only way I could refer to this script from console and execute the BatchRename function was

>>> filepath = bpy.path.abspath("//rename.py")
>>> exec(compile(open(filepath).read(), filepath, 'exec'))

Questions


Why the first script doesn't work?
What is the best working method to refer to Script from the Text Editor From Python Console?

Yuri Titko
  • 632
  • 2
  • 14

1 Answers1

-1

This isn't an answer to the scripting side of your question, but if you're looking to batch rename things in your file, there already exists a function for that.

It's called Batch Rename and it can be found in the Edit Menu. You can also call it with Ctrl + F2

enter image description here

It has several features to allow you to fine tweak the object names. You can also set it to discriminately rename only objects or only bones, etc.

Hope that helps.

Onyx
  • 1,661
  • 1
  • 7
  • 17
  • Thanks for the reply, I appreciate that, but I've already known about this feature. The main idia here is to make Python Console refer to functions from text editor =) – Yuri Titko Aug 03 '22 at 07:24