Page MenuHome

Multiple Objects Rename
Closed, ResolvedPublic

Description

Hi there

Multiple Objects Rename is one of the tools I made in BsMax add-on (UI Simulation) but I think this tool must be inside Blender.

Just a simple and useful tool, specially when I saw the new "F2" rename tool you added. This tool behaves the same but when more than one object is selected, it opens a secondary UI to rename multiple objects. I hope you find it useful and put it in Blender.


Details

Type
Patch

Event Timeline

Naser Merati (Nevil) changed the visibility from "Public (No Login Required)" to "All Users".
Naser Merati (Nevil) changed the edit policy from "Custom Policy" to "All Users".

@Campbell Barton (campbellbarton) perhaps we could add basic support for renaming multiple objects or bones to the Rename operator.

I’m not sure all these advanced options will fit though - might be best to keep those in a separate addon.

Brecht Van Lommel (brecht) changed the visibility from "All Users" to "Public (No Login Required)".Mar 27 2019, 9:20 PM
Brecht Van Lommel (brecht) triaged this task as Normal priority.

For many cases I would expect something simple like a basename.#### default value where the # gets replaced with digits. The basename could be extracted from the active or first selected object.

For other cases, maybe it would be good to enumerate some practical scenarios? It may be possible to have an enum with a few operations that cover the most common use cases:

  • Set Name
  • Find & Replace
  • Clean (remove unneeded numbers, make numbering consistent, trim whitespace, ...)
  • Trim (at start, at end, max length)

@Naser Merati (Nevil), not sure if you intend to contribute a complete patch that we can commit? If not I guess this is a good Quick Hack or UI Paper Cut for new contributors.

@William Reynish (billreynish), I'd like to keep context rename panel simple - where there is a name field you can edit and press enter.

We could have a "Batch Rename" toggle/enum that expands to show batch naming options.


Note that the current popup uses UI_BLOCK_POPOVER_ONCE - which allows typing in a value and pressing return to rename.

I'd like to keep this functionality (otherwise we'd need to press enter twice every time)

Some work needs to be done so clicking within the popup or pressing tab doesn't exit.


+1 for @Brecht Van Lommel (brecht)'s suggestions, for 2.4x we had batch renaming built-in, with set/find-replace/prefix/suffix as well as rename object names to match object data.

There are a lot of possible features here, suggest to start with basics and get that integrated into the current F2 panel that doesn't conflict with quick renaming.

@Campbell Barton (campbellbarton) Completely agree. There's a lot of value in the simplicity and speed of the current rename popup. I think we should keep that also.

That's why I suggested to just make it always rename all selected, rather than just the active item, but without adding all the complexity of this addon.

More features could either be exposed via a checkbox or a separate addon/operator.

Batch rename by default complicates things more then you might expect.

  • Pressing F2, Return will rename every other object to match the active objects name.
  • Minor edits will rename other objects (maybe OK, but also annoying if you didn't know another item was selected).
  • If you don't have an active object, there is no obvious name to pick from, so pressing enter will rename everyone to Untitled or do nothing?
  • If the active object isn't selected - intended outcome isn't clear.
  • As discussed previously, we could show object & object-data name, node & node-label etc, functionality with operating on the entire selection isn't obvious.

Would rather keep this a direct replacement for the "name" field in the properties buttons, then have batch operations as something that can be enabled.

Almost all our operators act on selected items, not just the active item. If I select four objects and use the Rename popup, I think I would expect and want it to rename all four. It would have to add .001, 002 etc, but that's fine.

Pressing enter will rename every other object to match the active objects name.

Yes, that would be the point :)

Minor edits will rename other objects (maybe OK, but also annoying if you didn't know another item was selected).

Same is true for any operator. Delete, for example.

If you don't have an active object, there is no obvious name to pick from, so pressing enter will rename everyone to Untitled or do nothing?

If you have no active object, but only selected objects, still just rename those selected items

As discussed previously, we could show object & object-data name, node & node-label etc, functionality with operating on the entire selection isn't obvious.

I think making it rename multiple items is more useful. And I think it's almost a good thing that there's only a single field. Keeps it simple and straight forward. The renaming item could change even more based on the context. Currently it allows renaming of objects or bones if in Object or Pose mode, but it could be even more context-aware and rename the mesh obData in Mesh Edit mode, etc.

If you have no active object, but only selected objects, still just rename those selected items

The field will be empty by default, just noting this might seem strange from a user perspective, eg:
you border select, press F2, Return then all your objects are called Untitled.


Think we should run this by artists in the studio, since it's possible you might want either behavior as default.

The down side w/ only supporting batch renaming is if you just want to rename the active item, you might not be able to use the quick F2 rename and go the the properties panel instead.

We could have both rename-active and batch-rename, remembering the last used, so both use cases are covered.

Yes that’s one way to go. The batch rename could be the more complex one with lots of options on how to sequence the batch, like the addon posted here.

Right, you shouldn't _have_ to touch these options if you dont want - type in text and press enter can still set the name of all selected objects when batch renaming, but you could also use find/replace etc if you wanted.

@Brecht Van Lommel (brecht)

basename.#### looks simple but always start from 0 or 1 and have not control to continue renaming from specific number but having control on number of digits is good idea.
I can add a automatic numbering option, that detect the last object in same name and continue renaming from that number.

About the enumerate, yeah its looks cool to be in that order and I`m on it and will complete that.

@Campbell Barton (campbellbarton)

The context rename panel still can be simple the batch rename panel open just when more than one object selected.

True. The batch renamer could launch when you have multiple items selected. This saves you from having to remember to separate hotkeys or commands.

  • Set Name
  • Find & Replace
  • Clean (remove unneeded numbers, make numbering consistent, trim whitespace, ...)
  • Trim (at start, at end, max length)

Set name is active object or active bone now. if active equals None first selected become default.
Fine & Replace is most useful option and now is second option
Clean unneeded numbers from first and last is next option
I think Prefix and suffix is useful too and in my opinion most be next
Numbered can be automatic and just use #### for count of digits
And In my opinion trim start and end most be default enabled to have an standard and clear Naming.
(maybe remove space or replace spaces with underline can be useful but find and replace already can do that)
Max Length can cause generate same name for multiple object do you think it is necessary ?

And on 'EDIT_ARMATURE' mode rename bones now.

But at the last I`ll do what is your decision.

@Naser Merati (Nevil) Looks good to me, if you can submit a patch that does that, if you have >1 object selected.

I tried two method with hashtags.

Once, find the biggest number in row and continue from that.
e.g. obj01, obj02, obj03 …., obj512
The problem I faced was if an object with same name and large number exist in scene numbers will continue after that. Even if previews object was deleted.

Second, find available numbers.
e.g. obj01, obj02, obj05, obj06, obj08
In this method number 3, 4, 7 and after 8 are free and can be used on numbering but it will become slow in a scene with a lot of objects. And user do not have control on numbers.
This is why I bring back the “Add Number” field.

And other thing I changed is, when one object or bone selected 'TOPBAR_PT_name' calls, otherwise multi rename calls.

If active object was deleted, the selected object turns to active. I did it in object mode but I did not find how I can set the ‘bone’ as ‘Active bone’. In line 130 passed that for now.


Seems quite good I think. @Campbell Barton (campbellbarton) will you check if you think the code is ok?

We could probably change the name from 'Rename Object(s)' to simply 'Rename Objects' since we know it will only spawn with multiple objects anyway.

@Naser Merati (Nevil) Probably you should submit it as an actual patch, rather than just as a Py file, and post using the official form here: https://developer.blender.org/differential/diff/create/

@William Reynish (billreynish) It`s OK. I`ll read and create a patch. thank you.

Sorry it toke long time I`m working on an add-on in the same time too.
I know you are buzzy but this is first time I`m using Github. And maybe I do a mistake and I don’t want to make a treble for you. For other tools I wrote this proses will be too shot and easy. For now I faced with many questions that confusing me.
Is this right? I have to make a diff file between the first file I sent and the edited new version of the same file as a *.diff file, that made by “git diff” command. And send it from “Create Diff” page. ?

@Naser Merati (Nevil) We use Git but not Microsoft Github,

Read here how to contribute code:
https://wiki.blender.org/wiki/Process/Contributing_Code

@Campbell Barton (campbellbarton)
The context rename panel still can be simple the batch rename panel open just when more than one object selected.

The problem with this is it forces users to de-select items just so they can rename a single item.

Having rename-active as default (as we have in the properties panel), with the option to batch rename (which is a more advanced operation anyway) seems a reasonable default.

If selecting between these actions is too much hassle it can be assigned a different shortcut.

I do not think its a problem, all standard tools works on selection.
e.g. Delete, Transform , Edit mode toggle, even Mesh editing tools.
if you want move only one object you have to de-select the others. or set one object to edit mode you have to de-select others. and there is no reason to add different short cuts for single and multiple mode.

And the question is, when the user do rename the object?
some time right after add the object, well now only one object selected and it is active. but most of time start to renaming after finishing the modeling of set, because of joining and separating while modeling and renaming before that is wasting time. I mean when you decide to start renaming, you just select and de-selecting for renaming.

Dear Campbell I know my code is not professional, I`m just learning for now. I understand you are working on great and impotent thing but you just missed simple but useful things. batch rename is one of them. just imagine you have a scene with thousand of objects and have to rename them? what will you do even whit latest version of the Grete Blender?

I had to submit the patch, but I was so busy last weeks sorry about that.

@Naser Merati (Nevil), this is mixing up topics.
Batch rename is important and we should add this ability (infact we had this in 2.4x, but it was never ported to newer Blender versions).

T61480 proposes to access object name as a popup, this is a quick, easy to access alternative to navigating to the object name field.
This should be kept working as-is for the same reason the object name field only accessed the active objects name in the properties editor.

I had a look into integrating batch rename into the existing UI, but it involves some development, so for now it's probably best these be separate operators.


As for this patch, the functionality should be generalized to operate on any kind of named data (bones, nodes, objects ... etc).
This can be done in Python without much extra effort.

hi, seems this is sidetracked? Is there any issue with adding this as an addon? If it's not an available feature in Blender, we could add it "until such time" that it's done in c.
The addon could appear in the Item Panel and overwrite the F2 hotkey. There's complex renamers being built atm, quite a few. It seems to me that this is a much needed function as it's kept coming up for years.
As it stands this addon fulfills the basic needs for selection based renaming.
Thanks.

One thing possibly missing here is to change Object and Object data names so they match

hi, seems this is sidetracked? Is there any issue with adding this as an addon?

  • Issues raised in Brecht's review should be addressed T63024#649841
  • It should work with non-object's too (bones, nodes, sequence strips etc), as the current F2 rename does.

If it's not an available feature in Blender, we could add it "until such time" that it's done in c.

This is fine to stay written in Python.

The addon could appear in the Item Panel and overwrite the F2 hotkey. There's complex renamers being built atm, quite a few. It seems to me that this is a much needed function as it's kept coming up for years.
As it stands this addon fulfills the basic needs for selection based renaming.
Thanks.

Sorry for my long delay, I just spend all of my time on other add-on. I will complete this one soon as possible.

@Naser Merati (Nevil) great, I think it would be good to have an initial version of this working with very few features ~ even a single new name, would be good (to get the details right - regarding different contexts). Then adding other features isn't so difficult.

OK, almost done.

I made different operators that share same UI for different modes "object.batchrename", "armature.batchrename", "sequencer.batchrename", "node.batchrename". and made it as an add-on that add key-maps too.
One extra option added for "node.batchrename" that lets user to change the Names or Labels.


And now I had to do the hardest part and made patch for it :D

Brendon Murphy (meta-androcto) raised the priority of this task from Normal to Confirmed, Medium.Jun 25 2019, 11:03 AM

hi, raising priority here, I think this is useful enough for inclusion in 2.8. A panel in the sidebar > Item tab would be good to have and easy to construct. There's not much time left so a couple of questions..
Are you prepared to maintain this addon in Blender during 2.8 series? Are you familiar with the git system? Are you prepared to handle bug reports?
You have been very good with handling suggestions and working together with devs, so you would be most welcome.
Thanks, let's try to make this happen.

William Reynish (billreynish) lowered the priority of this task from Confirmed, Medium to Normal.Jun 25 2019, 11:11 AM

@Naser Merati (Nevil) Great. Make a patch for it and it can be reviewed.

@Brendon Murphy (meta-androcto) No and no. The built-in batch renaming operator should not rely on users having the Sidebar open, and there’s no reason to permanently take up space there.

As for the priority, since it’s not a bug, the Confirmed status is not appropriate.

Was there any issue doing this in one operator? (it can work like the current rename operator).

@William Reynish (billrey) hi, maybe we are misunderstanding here? I was thinking this would not be done for 2.8 and we would use an addon to overwrite the keymaps and add a panel. It all would have been optional as an addon until such time you built it in. If your adding this as built in defaults, it's a great move.
Multi Objects Rename could still be an addon and only add a panel? I'm mainly looking at the 3d view where it could also be extended to include more advanced renaming techniques relevant to the 3d viewport. I was brainstorming on this recently with proxe and we came up with ideas like renaming objects within collections to match collection names and other useful scenarios.

Re status raise:
In the addons patch tracker the priority's are roughly as follows:
Confirmed High: Used for tasks affecting all addons. Current use is to highlight the removal of broken addons and track the movements.
Confirmed Medium: Used for tasks that are to be promoted to 2.8 or relative to addons known to be worked on for their inclusion/re-instated to release. These tasks are active and require activity.
Normal: Used to process incoming addons.

Thanks, let me know how you want to proceed. Maybe this task should be moved out of addons and a new task created if @Naser Merati (Nevil) wishes to maintain a rename panel addon for 2.8?

@Brendon Murphy (meta-androcto) Yes, I think there is a misunderstanding - as I see it, there’s no reason why we should not add batch renaming as a built-in feature. If you select more than one item, of course you want to affect those items, just like with any other operator. As such, we should just use a popup panel, and not litter the Sidebar with options for this.

Would rather postpone this, there are too many unfinished projects for 2.80 no need to add more.
We're likely to rush it and do it badly if this is made a 2.80 target.

See T63024#649880 for why this shouldn't be default.

Sure - let's postpose adding this to 2.81.

IMO, this should affect all selected items - if you only want to rename one item, you should just have one item selected - we do this for basically all other operators, ie delete, move, copy, paste and so on.

Sure - let's postpose adding this to 2.81.
IMO, this should affect all selected items - if you only want to rename one item, you should just have one item selected - we do this for basically all other operators, ie delete, move, copy, paste and so on.

The purpose of this was to be a quick way to edit the active items name, something which was exposed as a panel and is now exposed this way.

If we always batch rename it means we could add this back to the 3D views panel, but not sure that's an improvement.

Would rather make have batch rename as an option, or a separate shortcut.

@Campbell Barton (campbellbarton) Here's how I think it should work:

If you have one item selected, it could continue to work as it does now.
If you have >1 item selected, the same hotkey should launch Batch Rename

I don't think this means we'd have to add back the Item panel, no. This would be much superior to that, exactly because you could more easily affect multiple items.

@Campbell Barton (campbellbarton) As an 15 years generalist with a little scripting talent I think rename process is done after the modeling ended or right in creating time. F2 is a standard shortcut not just for applications but for OS's too and the purpose of that is renaming Selection as quickly as possible... if @Naser Merati's script keep Current function with one object selection, and run when the selection is more than one object and batch rename all selected Objects, then that is a must have inside Blender without need for any extra shortcut. it's fast and compatible to Blender's philosophy.

My concern is that renaming the active item is a simple action, you can think, F2, HomeKey, MyPrefix, Return.
A user can do this quickly without having to navigate a heavy interface or consider that you might also accidentally rename selected objects outside the view.

In contrast, batch renaming is an advanced action, something you setup and execute, like batch processing photos or bulk emailing, it's useful and you do it occasionally, but not a good default action.

There are many small features users will reasonably want (copy name from object-data, strip trailing digits, replace spaces with underscores, ... etc), the current patch proposed already has 9 options.

Before you know it, someone just wants to rename their object, they press F2 and they're faced with a wall of buttons


Whatever the case this doesn't need to be a 2.80 target so decisions can be postponed.

To me it seems reasonable to do a regular rename when one item is selected, but a batch rename with multiple items, while ensuring that the Return key always works properly to confirm, and that the focus is in the Name field by default.

We also should keep the Batch Rename UI at a reasonable size so it doesn't become the screenshot that @Campbell Barton (campbellbarton) posted.

As this task no longer relates to addons I'm removing addons project from this task and adding appropriate project tags.
@Naser Merati (Nevil) hi, I' would start a BA forum task with your latest addon version. At least that way users will have something to use in 2.8 and you can get valuable feedback on the addon/feature requests/usability and use that knowledge to advantage.
I'll start with a request to add a panel to the addon.
Thanks, good luck in your future endeavors.

To me it seems reasonable to do a regular rename when one item is selected, but a batch rename with multiple items, while ensuring that the Return key always works properly to confirm, and that the focus is in the Name field by default.

It may be that a good batch rename UI doesn't fit well for quickly renaming the active item.

We also should keep the Batch Rename UI at a reasonable size so it doesn't become the screenshot that @Campbell Barton (campbellbarton) posted.

Agree, nevertheless - this kind of feature tends towards feature-creep, since users can come up with a compelling use case for <renumbering/regex/upper/lowercase/replacing...> etc,
We can manage this (hide behind an "advanced" checkbox for eg).

@Brendon Murphy (meta-androcto)
Are you prepared to maintain this addon in Blender during 2.8 series? yes
Are you familiar with the git system? Not yet but its most be easy
Are you prepared to handle bug reports? Yeap
I' would start a BA forum task..... > Good idea, thank you.
@Campbell Barton (campbellbarton)
But this tool just appears when more then one items selected other ways "Rename active items" is appear.
Yeah, Ideas about Cap sensitive or upper, lower case is cool and I will add that functions too.
@William Reynish (billreynish)
No matter how, internal or external add-on. Matter is User has this ability to use this tool.
I think this most be fine to see Users feed backs, and update it until become almost perfect to fit in Blender.
My goal is learn how to contribute with Blender Team. This is just a start with a very simple tool.

@Campbell Barton (campbellbarton)
But this tool just appears when more then one items selected other ways "Rename active items" is appear.

I understand, but think tools being predictable is important and am not convinced this is necessarily a good idea... see previous comments on this.

Yeah, Ideas about Cap sensitive or upper, lower case is cool and I will add that functions too.

Eventually these features could be added, for now I'd prefer have a basic patch reviewed and accepted first.

Just for reference I'll leave a link to what I consider one of the most competent and comprehensive Blender batch rename addons Name Panel or the 2.8 version nS, including options to batch transfer names between datablocks.

While I understand the need to keep the UI simple (batch renaming does tend to lean towards feature creep), maybe the default dialog could remain simple, with just an Object Name and Object Data name field.
Default behavior would be to batch rename all selected items. The mentioned issues above with having no active item are relatively minor compared to the advantages I believe, at least no different than with all other operators in Blender.

One could then have and "Advanced" button or an ellipsis "..." that opened the advanced dialog with all the batch rename bells and whistles. Maybe addons could register shortcut buttons to this dialog, or the ellipsis opens a menu/list with all current batch rename addons.

@Duarte Farrajota Ramos (duarteframos) some compromise may work.

Without working code this is too much speculation.

I'd rather postpone this until the patch is closer to a finished state and 2.80 is released.

Ended up committing rBa5b1231de790: WM: batch rename operator basic batch renaming support, which uses the same code for objects, bones.. etc.

Other features can be added as needed.