2025-07-01

This commit is contained in:
2026-03-17 14:30:01 -06:00
parent f9a22056dd
commit 62b5978595
4579 changed files with 1257472 additions and 0 deletions
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -0,0 +1,16 @@
Documentation: https://weisl.github.io/renaming_overview/
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?hosted_button_id=JV7KRF77TY78A)
<h1>Introduction</h1>
<p><b> Simple Renaming Panel </b> is a small, but powerful tool to rename more objects at once. The tool includes basic functionalities of adding suffixes, prefixes, search and replace, add suffixes depending on the object type and much more. Over the time more advanced features like a variable system were added. The tool gives a lot of power to you!
You decide which kind of objects will be affected by the renaming task. Rename all or just selected objects, specify the affected object types like image textures, materials, objects, object data, bones, or collections. This tool can be a real everyday helper. Renaming multiple objects is often needed and keeping the naming conventions can be tedious. The tool provides you with a clear feedback of what has been renamed. This tool is kept simple to be user-friendly but offers everything you need to stay organized. </p>
Join the discussion at [Blender Artists](https://blenderartists.org/t/simple-renaming-panel/676639 "Blender Artists").
You can thank me by leaving a rating at [Gumroad](https://gumroad.com/l/simple_renaming "Gumroad") or sponsor a
coffee.
Documentation: https://weisl.github.io/renaming_overview/
@@ -0,0 +1,59 @@
"""
Copyright (C) 2019 Matthias Patscheider
patscheider.matthias@gmail.com
Created by Matthias Patscheider
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# support reloading sub-modules
if "bpy" in locals():
import importlib
importlib.reload(add_suffix_panel)
importlib.reload(operators)
importlib.reload(preferences)
importlib.reload(ui)
importlib.reload(variable_replacer)
else:
from . import add_suffix_panel
from . import operators
from . import preferences
from . import ui
from . import variable_replacer
files = [
add_suffix_panel,
operators,
ui,
# keymap and preferences should be last
preferences,
]
def register():
for file in files:
file.register()
def unregister():
for file in reversed(files):
file.unregister()
if __name__ == "__main__":
register()
@@ -0,0 +1,178 @@
import bpy
from bpy.props import (
BoolProperty,
EnumProperty,
StringProperty,
)
from . import renaming_sufPre_operators
def variable_replacer(self, context):
wm = bpy.context.scene
# The print function works fine
renaming_variable = context.scene.renaming_variables
name_var = ""
# System and Global Values
if renaming_variable == 'FILE':
name_var = "@f"
if renaming_variable == "DATE":
name_var = "@d"
if renaming_variable == "TIME":
name_var = "@i"
if renaming_variable == "RANDOM":
name_var = "@r"
# UserStrings
if renaming_variable == "HIGH":
name_var = "@h"
if renaming_variable == "LOW":
name_var = "@l"
if renaming_variable == "CAGE":
name_var = "@b"
if renaming_variable == "USER1":
name_var = "@u1"
if renaming_variable == "USER2":
name_var = "@u2"
if renaming_variable == "USER3":
name_var = "@u3"
if renaming_variable == "NUMERATE":
name_var = "@n"
if wm.renaming_object_types == 'OBJECT':
if renaming_variable == 'OBJECT':
name_var = "@o"
if renaming_variable == "TYPE":
name_var = "@t"
if renaming_variable == "PARENT":
name_var = "@p"
if renaming_variable == "ACTIVE":
name_var = "@a"
if renaming_variable == "COLLECTION":
name_var = "@c"
if renaming_variable == "DATA":
name_var = "@m"
context.scene.renaming_new_name += str(name_var)
return
classes = (
renaming_sufPre_operators.VIEW3D_OT_add_type_suf_pre,
)
enumPresetItems = [('FILE', "File", "", '', 1),
('OBJECT', "Object", "", '', 2),
('HIGH', "High", "", '', 4),
('LOW', "Low", "", '', 8),
('CAGE', "Cage", "", '', 16),
('DATE', "Date", "", '', 32),
('TIME', "Time", "", '', 128),
('TYPE', "Type", "", '', 1024),
('PARENT', "Parent", "", '', 2048),
('ACTIVE', "Active", "", '', 4096),
('USER1', "User1", "", '', 8192),
('USER2', "User2", "", '', 256),
('USER3', "User3", "", '', 512),
('NUMBER', "Number", "", '', 1024),
('DATA', "Data", "", '', 2048),
]
enumObjectTypesExt = [('EMPTY', "", "Rename empty objects", 'OUTLINER_OB_EMPTY', 1),
('MESH', "", "Rename mesh objects", 'OUTLINER_OB_MESH', 2),
('CAMERA', "", "Rename Camera objects", 'OUTLINER_OB_CAMERA', 4),
('LIGHT', "", "Rename light objects", 'OUTLINER_OB_LIGHT', 8),
('ARMATURE', "", "Rename armature objects", 'OUTLINER_OB_ARMATURE', 16),
('LATTICE', "", "Rename lattice objects", 'OUTLINER_OB_LATTICE', 32),
('CURVE', "", "Rename curve objects", 'OUTLINER_OB_CURVE', 64),
('SURFACE', "", "Rename surface objects", 'OUTLINER_OB_SURFACE', 128),
('TEXT', "", "Rename text objects", 'OUTLINER_OB_FONT', 256),
('GPENCIL', "", "Rename greace pencil objects", 'OUTLINER_OB_GREASEPENCIL', 512),
('METABALL', "", "Rename metaball objects", 'OUTLINER_OB_META', 2048),
('COLLECTION', "", "Rename collections", 'GROUP', 4096),
('BONE', "", "", 'BONE_DATA', 8192), ]
def register():
id_store = bpy.types.Scene
# Type Suffix Prefix
id_store.type_pre_sub_only_selection = BoolProperty(
name="Selected Objects",
description="Rename Selected Objects",
default=True,
)
id_store.renaming_suffix_prefix_types_specified = EnumProperty(name="Object Types",
items=enumObjectTypesExt,
description="Which kind of object to rename",
options={'ENUM_FLAG'},
default={'CURVE', 'LATTICE', 'SURFACE', 'METABALL',
'MESH',
'ARMATURE', 'LIGHT', 'CAMERA', 'EMPTY',
'GPENCIL',
'TEXT', 'BONE', 'COLLECTION'}
)
id_store.renaming_suffix_prefix_material = StringProperty(name='Material', default='')
id_store.renaming_suffix_prefix_geometry = StringProperty(name='Geometry', default='')
id_store.renaming_suffix_prefix_empty = StringProperty(name="Empty", default='')
id_store.renaming_suffix_prefix_group = StringProperty(name="Group", default='')
id_store.renaming_suffix_prefix_curve = StringProperty(name="Curve", default='')
id_store.renaming_suffix_prefix_armature = StringProperty(name="Armature", default='')
id_store.renaming_suffix_prefix_lattice = StringProperty(name="Lattice", default='')
id_store.renaming_suffix_prefix_data = StringProperty(name="Data", default='')
id_store.renaming_suffix_prefix_data_02 = StringProperty(name="Data = Objectname + ", default='')
id_store.renaming_suffix_prefix_surfaces = StringProperty(name="Surfaces", default='')
id_store.renaming_suffix_prefix_cameras = StringProperty(name="Cameras", default='')
id_store.renaming_suffix_prefix_lights = StringProperty(name="Lights", default='')
id_store.renaming_suffix_prefix_collection = StringProperty(name="Collections", default='')
id_store.renaming_suffix_prefix_text = StringProperty(name="Text", default='')
id_store.renaming_suffix_prefix_gpencil = StringProperty(name="Grease Pencil", default='')
id_store.renaming_suffix_prefix_metaball = StringProperty(name="Metaballs", default='')
id_store.renaming_suffix_prefix_bone = StringProperty(name="Bones", default='')
id_store.renaming_suffix_prefix_speakers = StringProperty(name="Speakers", default='')
id_store.renaming_suffix_prefix_lightprops = StringProperty(name="LightProps", default='')
id_store.renaming_inputContext = StringProperty(name="LightProps", default='')
id_store.renaming_variables = EnumProperty(name="Object Types",
items=enumPresetItems,
description="Which kind of object to rename",
update=variable_replacer
)
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
id_store = bpy.types.Scene
del id_store.renaming_suffix_prefix_material
del id_store.renaming_suffix_prefix_geometry
del id_store.renaming_suffix_prefix_empty
del id_store.renaming_suffix_prefix_group
del id_store.renaming_suffix_prefix_curve
del id_store.renaming_suffix_prefix_armature
del id_store.renaming_suffix_prefix_lattice
del id_store.renaming_suffix_prefix_data
del id_store.renaming_suffix_prefix_data_02
del id_store.renaming_start_number
del id_store.renaming_suffix_prefix_lights
del id_store.renaming_suffix_prefix_cameras
del id_store.renaming_suffix_prefix_surfaces
del id_store.renaming_suffix_prefix_bone
del id_store.renaming_suffix_prefix_collection
del id_store.renaming_object_types_specified
del id_store.renaming_suffix_prefix_speakers
del id_store.renaming_suffix_prefix_lightprops
@@ -0,0 +1,325 @@
import bpy
from bpy.props import (
StringProperty,
)
from ..operators.renaming_utilities import call_renaming_popup
def suffix_prefix_add(context, obj, suffix_prefix_name):
wm = context.scene
new_name = obj.name
if wm.renaming_suffix_prefix_type == 'SUF':
new_name = new_name + suffix_prefix_name
else:
new_name = suffix_prefix_name + new_name
if new_name not in bpy.data.objects:
obj.name = new_name
return new_name
else:
i = 1
while new_name in bpy.data.objects:
if wm.renaming_suffix_prefix_type == 'SUF':
new_name = obj.name + "_" + str(i) + suffix_prefix_name
else:
new_name = suffix_prefix_name + obj.name + "_" + str(i)
i = i + 1
obj.name = new_name
return new_name
class VIEW3D_OT_add_type_suf_pre(bpy.types.Operator):
"""Add Type Suffix"""
bl_idname = "renaming.add_suffix_prefix_by_type"
bl_label = "Add Type Suffix or Prefix"
bl_description = "Adds the above defined Suffixes or Prefixes to all objects in your scene"
bl_options = {'REGISTER', 'UNDO'}
option: StringProperty()
def __init__(self):
self.context = None
def get_selection_all(self):
context = self.context
use_selection = context.scene.type_pre_sub_only_selection
if use_selection:
return context.selected_objects.copy()
else:
return bpy.data.objects
def rename_suffix_prefix(self, obj_list, pre_suffix='', object_type='', icon=''):
context = self.context
wm = context.scene
new_name = ''
switch_suf_pre = wm.renaming_suffix_prefix_type # either use pre of suffix
if pre_suffix != '':
for ent in obj_list:
if hasattr(ent, 'name'):
old_name = ent.name
name_is_new = True
if switch_suf_pre == 'SUF':
if not ent.name.endswith(pre_suffix):
new_name = suffix_prefix_add(context, ent, pre_suffix)
else:
name_is_new = False
else:
if not ent.name.startswith(pre_suffix):
new_name = suffix_prefix_add(context, ent, pre_suffix)
else:
name_is_new = False
if name_is_new:
ent.name = new_name
wm.renaming_messages.add_message(old_name, ent.name, object_type, icon)
else:
# wm.renaming_messages.add_message(old_name, ent.name, objectType, 'OUTLINER_OB_EMPTY')
pass
def empty(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'EMPTY':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_empty, object_type='EMPTY',
icon='OUTLINER_OB_EMPTY')
return
def mesh(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'MESH':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_geometry, object_type='MESH',
icon='OUTLINER_OB_MESH')
return
def material(self):
context = self.context
wm = context.scene
obj_list = []
if wm.type_pre_sub_only_selection:
for obj in context.selected_objects:
for mat in obj.material_slots:
if mat is not None and mat.name != '':
obj_list.append(bpy.data.materials[mat.name])
else:
obj_list = list(bpy.data.materials)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_material, object_type='MATERIAL',
icon='MATERIAL')
return
def speakers(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'SPEAKER':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_speakers, object_type='SPEAKER',
icon='OUTLINER_OB_SPEAKER')
return
def lightprops(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'LIGHT_PROBE':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_lightprops, object_type='LIGHT_PROBE',
icon='OUTLINER_OB_LIGHTPROBE')
return
def data(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
obj_list.append(obj.data)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_data, object_type='DATA', icon='FILE_BLANK')
return
def camera(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'CAMERA':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_cameras, object_type='CAMERA',
icon='OUTLINER_OB_CAMERA')
return
def light(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'LIGHT':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_lights, object_type='LIGHT', icon='LIGHT')
return
def armature(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'ARMATURE':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_armature, object_type='ARMATURE',
icon='OUTLINER_OB_ARMATURE')
return
def lattice(self):
wm = bpy.context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'LATTICE':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_lattice, object_type='LATTICE',
icon='OUTLINER_OB_LATTICE')
return
def curve(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'CURVE':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_curve, object_type='CURVE',
icon='OUTLINER_OB_CURVE')
return
def surface(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'SURFACE':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_surfaces, object_type='SURFACE',
icon='OUTLINER_OB_SURFACE')
return
def text(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'FONT':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_text, object_type='FONT',
icon='OUTLINER_OB_FONT')
return
def gpencil(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'GPENCIL':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_gpencil, object_type='GPENCIL',
icon='OUTLINER_OB_GREASEPENCIL')
return
def metaball(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'META':
obj_list.append(obj)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_metaball, object_type='META',
icon='OUTLINER_OB_META')
return
def collection(self):
context = self.context
wm = context.scene
obj_list = []
for col in bpy.data.collections:
obj_list.append(col)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_collection, object_type='COLLECTION',
icon='GROUP')
return
def bone(self):
context = self.context
wm = context.scene
obj_list = []
for obj in self.get_selection_all():
if obj.type == 'ARMATURE':
for bone in obj.data.bones:
obj_list.append(bone)
self.rename_suffix_prefix(obj_list, pre_suffix=wm.renaming_suffix_prefix_bone, object_type='BONE', icon='BONE_DATA')
return
def all(self):
self.empty()
self.mesh()
self.camera()
self.light()
self.armature()
self.lattice()
self.curve()
self.surface()
self.text()
self.gpencil()
self.metaball()
self.collection()
self.bone()
self.material()
self.data()
def error_msg(self):
pass
def switch_type(self, argument):
method = getattr(self, argument, lambda: "Invalid Type")
return method()
def main(self, context, object_list, is_suffix, string_extension):
pass
def execute(self, context):
self.context = context
self.switch_type(self.option)
call_renaming_popup(context)
return {'FINISHED'}
@@ -0,0 +1,29 @@
schema_version = "1.0.0"
id = "simple_renaming_panel"
version = "2.1.4"
name = "Simple Renaming"
tagline = "Effortlessly rename multiple objects with this simple addon"
maintainer = "Matthias Patscheider <patscheider.matthias@gmail.com>"
type = "add-on"
website = "https://weisl.github.io/renaming_overview/"
tags = ["3D View", "Scene", "User Interface"]
blender_version_min = "4.2.0"
license = [
"SPDX:GPL-3.0-or-later",
]
copyright = [
"2024 Matthias Patscheider",
]
[build]
paths_exclude_pattern = [
"__pycache__/",
"/.git/",
"/*.zip",
]
@@ -0,0 +1,196 @@
import bpy
from bpy.app.handlers import persistent
from bpy.props import (
BoolProperty,
EnumProperty,
StringProperty,
IntProperty,
IntVectorProperty,
)
from . import add_pre_suffix
from . import name_from_data
from . import name_replace
from . import numerate
from . import search_replace
from . import search_select
from . import trim_string
from .renaming_utilities import update_selection_order
enumObjectTypes = [('EMPTY', "", "Rename empty objects", 'OUTLINER_OB_EMPTY', 1),
('MESH', "", "Rename mesh objects", 'OUTLINER_OB_MESH', 2),
('CAMERA', "", "Rename Camera objects", 'OUTLINER_OB_CAMERA', 4),
('LIGHT', "", "Rename light objects", 'OUTLINER_OB_LIGHT', 8),
('ARMATURE', "", "Rename armature objects", 'OUTLINER_OB_ARMATURE', 16),
('LATTICE', "", "Rename lattice objects", 'OUTLINER_OB_LATTICE', 32),
('CURVE', "", "Rename curve objects", 'OUTLINER_OB_CURVE', 64),
('SURFACE', "", "Rename surface objects", 'OUTLINER_OB_SURFACE', 128),
('FONT', "", "Rename font objects", 'OUTLINER_OB_FONT', 256),
('GPENCIL', "", "Rename greace pencil objects", 'OUTLINER_OB_GREASEPENCIL', 512),
('META', "", "Rename metaball objects", 'OUTLINER_OB_META', 1024),
('SPEAKER', "", "Rename empty speakers", 'OUTLINER_OB_SPEAKER', 2048),
('LIGHT_PROBE', "", "Rename mesh lightpropes", 'OUTLINER_OB_LIGHTPROBE', 4096),
('VOLUME', "", "Rename mesh volumes", 'OUTLINER_OB_VOLUME', 8192)]
enumObjectTypesAdd = [('SPEAKER', "", "Rename empty speakers", 'OUTLINER_OB_SPEAKER', 1),
('LIGHT_PROBE', "", "Rename mesh lightpropes", 'OUTLINER_OB_LIGHTPROBE', 2)]
prefixSuffixItems = [('PRE', "Prefix", "prefix"),
('SUF', "Suffix", "suffix")
]
renamingEntitiesItems = [('OBJECT', "Object", "Scene Objects"),
('MATERIAL', "Material", "Materials"),
('COLLECTION', "Collection", "Rename collections"),
None,
('DATA', "Data", "Object Data"),
None,
('BONE', "Bone", "Bones"),
('IMAGE', "Image Textures", "Image Textures"),
None,
('MODIFIERS', "Modifiers", "Rename Modifiers"),
('SHAPEKEYS', "Shape Keys", "Rename shape keys"),
None,
('ATTRIBUTES', "Attributes", "Rename attributes"),
('COLORATTRIBUTES', "Color Attributes", "Rename color attributes"),
('UVMAPS', "UV Maps", "Rename vertex groups"),
('VERTEXGROUPS', "Vertex Groups", "Rename vertex groups"),
None,
('ACTIONS', "Actions", "Rename Actions"),
None,
('PARTICLESYSTEM', "Particle Systems", "Rename particle systems"),
('PARTICLESETTINGS', "Particle Settings", "Rename particle settings"),
]
classes = (
search_select.VIEW3D_OT_search_and_select,
search_replace.VIEW3D_OT_search_and_replace,
name_replace.VIEW3D_OT_replace_name,
trim_string.VIEW3D_OT_trim_string,
add_pre_suffix.VIEW3D_OT_add_suffix,
add_pre_suffix.VIEW3D_OT_add_prefix,
numerate.VIEW3D_OT_renaming_numerate,
name_from_data.VIEW3D_OT_use_objectname_for_data,
)
enum_sort_items = [('X', "X Axis", "Sort the object based on the X axis."),
('Y', "Y Axis", "Sort the object based on the Y axis."),
('Z', "Z Axis", "Sort the object based on the Z axis."),
('SELECTION', "Selection", "Sort the objects based on the selection order"), ]
enum_sort_bone_items = [('X', "X Axis", "Sort the object based on the X axis."),
('Y', "Y Axis", "Sort the object based on the Y axis."),
('Z', "Z Axis", "Sort the object based on the Z axis."), ]
# persistent is needed for handler to work in addons https://docs.blender.org/api/current/bpy.app.handlers.html
@persistent
def PostChange(scene):
if bpy.context.mode != "OBJECT":
return
# Any() function returns True if any element of an iterable is True. If not, it returns False.
is_selection_update = any(
not u.is_updated_geometry
and not u.is_updated_transform
and not u.is_updated_shading
for u in bpy.context.view_layer.depsgraph.updates
)
if is_selection_update:
update_selection_order()
def register():
id_store = bpy.types.Scene
id_store.renaming_suffix_prefix_type = EnumProperty(name="Suffix or Prefix by Type",
items=prefixSuffixItems,
description="Add Prefix or Suffix to type",
default='SUF'
)
id_store.renaming_object_types = EnumProperty(name="Renaming Objects",
items=renamingEntitiesItems,
description="Which kind of object to rename",
)
id_store.renaming_object_types_specified = EnumProperty(name="Object Types",
items=enumObjectTypes,
description="Which kind of object to rename",
options={'ENUM_FLAG'},
default={'CURVE', 'LATTICE', 'SURFACE', 'MESH',
'ARMATURE', 'LIGHT', 'CAMERA', 'EMPTY', 'GPENCIL',
'FONT', 'SPEAKER', 'LIGHT_PROBE', 'VOLUME'}
)
id_store.renaming_sort_enum = EnumProperty(
name="Sort by",
description="Sort Objects based on following attribute",
items=enum_sort_items,
default='X', # Set a default value
)
id_store.renaming_sort_bone_enum = EnumProperty(
name="Sort by",
description="Sort Bones based on following attribute",
items=enum_sort_bone_items,
default='X', # Set a default value
)
id_store.renaming_new_name = StringProperty(name="New Name", default='')
id_store.renaming_search = StringProperty(name='Search', default='')
id_store.renaming_replace = StringProperty(name='Replace', default='')
id_store.renaming_suffix = StringProperty(name="Suffix", default='')
id_store.renaming_prefix = StringProperty(name="Prefix", default='')
id_store.renaming_numerate = StringProperty(name="Numerate", default='###')
id_store.renaming_sorting = bpy.props.BoolProperty(
name="Sort Target Objects",
description="Sort the entries for renaming",
default=False,
)
id_store.renaming_sort_reverse = BoolProperty(name="Reverse Sorting Order", default=False)
id_store.renaming_only_selection = BoolProperty(name="Selected Objects", description="Rename Selected Objects",
default=True)
id_store.renaming_matchcase = BoolProperty(name="Match Case", description="", default=True)
id_store.renaming_useRegex = BoolProperty(name="Use Regex", description="", default=False)
id_store.renaming_use_enumerate = BoolProperty(name="Numerate",
description="Enable and Disable the numeration of objects. This can "
"be especially useful in combination with the numeration "
"variable @n",
default=True,
)
id_store.renaming_base_numerate = IntProperty(name="Step Size", default=1)
id_store.renaming_start_number = IntProperty(name="Step Size", default=1)
id_store.renaming_digits_numerate = IntProperty(name="Number Length", default=3)
id_store.renaming_trim_indices = IntVectorProperty(name="Trim Size", default=(0, 0), min=0, soft_min=0, size=2)
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.app.handlers.depsgraph_update_post.append(PostChange)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
IDStore = bpy.types.Scene
del IDStore.renaming_search
del IDStore.renaming_new_name
del IDStore.renaming_object_types
del IDStore.renaming_suffix_prefix_type
del IDStore.renaming_replace
del IDStore.renaming_suffix
del IDStore.renaming_prefix
del IDStore.renaming_only_selection
del IDStore.renaming_base_numerate
del IDStore.renaming_digits_numerate
del IDStore.renaming_trim_indices
bpy.app.handlers.depsgraph_update_post.remove(PostChange)
@@ -0,0 +1,81 @@
import bpy
from .renaming_operators import switch_to_edit_mode
from ..operators.renaming_utilities import get_renaming_list, call_renaming_popup, call_error_popup
from ..variable_replacer.variable_replacer import VariableReplacer
class VIEW3D_OT_add_suffix(bpy.types.Operator):
bl_idname = "renaming.add_suffix"
bl_label = "Add suffix"
bl_description = "Adds a suffix to object names"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
wm = context.scene
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
msg = wm.renaming_messages
VariableReplacer.reset()
if len(renaming_list) > 0:
for entity in renaming_list:
if entity is not None:
suffix = VariableReplacer.replaceInputString(context, wm.renaming_suffix, entity)
if not entity.name.endswith(suffix):
oldName = entity.name
new_name = entity.name + suffix
entity.name = new_name
msg.add_message(oldName, entity.name)
else:
msg.add_message(None, None, "Insert Valid String")
if switch_edit_mode:
switch_to_edit_mode(context)
call_renaming_popup(context)
return {'FINISHED'}
class VIEW3D_OT_add_prefix(bpy.types.Operator):
bl_idname = "renaming.add_prefix"
bl_label = "Add Prefix"
bl_description = "Adds a prefix to object names"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
wm = context.scene
msg = wm.renaming_messages
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
VariableReplacer.reset()
if len(renaming_list) > 0:
for entity in renaming_list:
if entity is not None:
pre = VariableReplacer.replaceInputString(context, wm.renaming_prefix, entity)
if not entity.name.startswith(pre):
oldName = entity.name
new_name = pre + entity.name
entity.name = new_name
msg.add_message(oldName, entity.name)
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,38 @@
import bpy
from .renaming_operators import switch_to_edit_mode
from .renaming_utilities import get_renaming_list, call_error_popup, call_renaming_popup
class VIEW3D_OT_use_objectname_for_data(bpy.types.Operator):
bl_idname = "renaming.data_name_from_obj"
bl_label = "Data Name from Object"
bl_description = "Renames the object data according to the object name and adds the in the data textfield " \
"specified suffix. "
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
wm = context.scene
suffix_data = wm.renaming_suffix_prefix_data_02
msg = context.scene.renaming_messages
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
for obj in renaming_list:
if obj.data:
oldName = obj.data.name
new_name = obj.name + suffix_data
obj.data.name = new_name
msg.add_message(oldName, obj.data.name)
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,159 @@
import bpy
from .renaming_operators import getAllVertexGroups, getAllAttributes, getAllBones, getAllModifiers, getAllUvMaps, \
getAllColorAttributes, getAllParticleNames, getAllParticleSettingsNames, getAllDataNames, getAllShapeKeys
from .renaming_operators import switch_to_edit_mode, numerate_entity_name
from ..operators.renaming_utilities import get_renaming_list, call_renaming_popup, call_error_popup
from ..variable_replacer.variable_replacer import VariableReplacer
class VIEW3D_OT_replace_name(bpy.types.Operator):
bl_idname = "renaming.name_replace"
bl_label = "Replace Names"
bl_description = "replaces the names of the objects"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = context.scene
replaceName = scene.renaming_new_name
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = scene.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
old_mode = context.mode
# settings for numerating the new name
msg = scene.renaming_messages
vertexGroupNameList = []
particleSettingsList = []
particleList = []
uvmapsList = []
dataList = []
attributeList = []
colorAttributeList = []
shapeKeyNamesList = []
modifierNamesList = []
boneList = []
if context.scene.renaming_object_types == 'VERTEXGROUPS':
vertexGroupNameList = getAllVertexGroups()
if scene.renaming_object_types == 'PARTICLESYSTEM':
particleList = getAllParticleNames()
if scene.renaming_object_types == 'PARTICLESETTINGS':
particleSettingsList = getAllParticleSettingsNames()
if context.scene.renaming_object_types == 'UVMAPS':
uvmapsList = getAllUvMaps()
if context.scene.renaming_object_types == 'COLORATTRIBUTES':
colorAttributeList = getAllColorAttributes()
if context.scene.renaming_object_types == 'ATTRIBUTES':
attributeList = getAllAttributes()
if scene.renaming_object_types == 'SHAPEKEYS':
shapeKeyNamesList = getAllShapeKeys()
if scene.renaming_object_types == 'MODIFIERS':
modifierNamesList = getAllModifiers()
if scene.renaming_object_types == 'BONE':
boneList = getAllBones(old_mode)
if scene.renaming_object_types == 'DATA':
dataList = getAllDataNames()
VariableReplacer.reset()
if len(str(replaceName)) > 0: # New name != empty
if len(renaming_list) > 0: # List of objects to rename != empty
for entity in renaming_list:
if entity is not None:
replaceName = VariableReplacer.replaceInputString(context, scene.renaming_new_name, entity)
oldName = entity.name
new_name = ''
if not scene.renaming_use_enumerate:
entity.name = replaceName
msg.add_message(oldName, entity.name)
else: # if scene.renaming_use_enumerate == True
if scene.renaming_object_types == 'OBJECT':
new_name = numerate_entity_name(context, replaceName, bpy.data.objects, entity.name)
elif scene.renaming_object_types == 'MATERIAL':
new_name = numerate_entity_name(context, replaceName, bpy.data.materials, entity.name)
elif scene.renaming_object_types == 'IMAGE':
new_name = numerate_entity_name(context, replaceName, bpy.data.images, entity.name)
elif scene.renaming_object_types == 'DATA':
new_name, dataList = numerate_entity_name(context, replaceName, dataList, entity.name,
return_type_list=True)
elif scene.renaming_object_types == 'BONE':
new_name, boneList = numerate_entity_name(context, replaceName, boneList, entity.name,
return_type_list=True)
elif scene.renaming_object_types == 'COLLECTION':
new_name = numerate_entity_name(context, replaceName, bpy.data.collections, entity.name)
elif scene.renaming_object_types == 'ACTIONS':
new_name = numerate_entity_name(context, replaceName, bpy.data.actions, entity.name)
elif scene.renaming_object_types == 'SHAPEKEYS':
new_name, shapeKeyNamesList = numerate_entity_name(context, replaceName,
shapeKeyNamesList, entity.name,
return_type_list=True)
elif scene.renaming_object_types == 'MODIFIERS':
new_name, modifierNamesList = numerate_entity_name(context, replaceName,
modifierNamesList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'VERTEXGROUPS':
new_name, vertexGroupNameList = numerate_entity_name(context, replaceName,
vertexGroupNameList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'PARTICLESYSTEM':
new_name, particleList = numerate_entity_name(context, replaceName,
particleList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'PARTICLESETTINGS':
new_name, particleSettingsList = numerate_entity_name(context, replaceName,
particleSettingsList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'UVMAPS':
new_name, uvmapsList = numerate_entity_name(context, replaceName,
uvmapsList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'ATTRIBUTES':
new_name, attributeList = numerate_entity_name(context, replaceName,
attributeList, entity.name,
return_type_list=True)
elif context.scene.renaming_object_types == 'COLORATTRIBUTES':
new_name, colorAttributeList = numerate_entity_name(context, replaceName,
colorAttributeList, entity.name,
return_type_list=True)
try:
entity.name = new_name
msg.add_message(oldName, entity.name)
except AttributeError:
print("Attribute {} is read only".format(new_name))
else: # len(str(replaceName)) <= 0
msg.add_message(None, None, "Insert a valid string to replace names")
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,49 @@
import bpy
from .renaming_operators import switch_to_edit_mode
from .. import __package__ as base_package
from ..operators.renaming_utilities import get_renaming_list, call_renaming_popup, call_error_popup
class VIEW3D_OT_renaming_numerate(bpy.types.Operator):
bl_idname = "renaming.numerate"
bl_label = "Numerate"
bl_description = "adds a growing number to the object names with the amount of digits specified in Number Length"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
prefs = context.preferences.addons[base_package].preferences
separator = prefs.renaming_separator
wm = context.scene
start_number = prefs.numerate_start_number
step = prefs.numerate_step
digits = prefs.numerate_digits
msg = wm.renaming_messages
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
if len(renaming_list) > 0:
i = 0
for entity in renaming_list:
if entity is not None:
oldName = entity.name
new_name = entity.name + separator + (
'{num:{fill}{width}}'.format(num=(i * step) + start_number, fill='0', width=digits))
entity.name = new_name
msg.add_message(oldName, entity.name)
i = i + 1
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,148 @@
import bpy
from .. import __package__ as base_package
def switch_to_edit_mode(context):
"""Switch to Edit Mode"""
bpy.ops.object.mode_set(mode='EDIT')
def numerate_entity_name(context, basename, type_list, active_entity_name, return_type_list=False):
"""Numerate entities and make sure they have a unique number"""
wm = context.scene
digits = len(wm.renaming_numerate)
# Preferences
prefs = context.preferences.addons[base_package].preferences
separator = prefs.renaming_separator
start_number = prefs.numerate_start_number
step = prefs.numerate_step
i = 0
new_name = basename + separator + (
'{num:{fill}{width}}'.format(num=(i * step) + start_number, fill='0', width=digits))
i = 1
while new_name in type_list and new_name != active_entity_name:
new_name = basename + separator + (
'{num:{fill}{width}}'.format(num=(i * step) + start_number, fill='0', width=digits))
i += 1
if return_type_list: # Manually add new name to custom generated list like all bones and all shape keys
type_list.append(new_name)
return new_name, type_list
return new_name
def getAllBones(mode):
"""Get list of all bones depending on Edit or Pose Mode"""
boneList = []
for arm in bpy.data.armatures:
if mode == 'POSE':
for bone in arm.bones:
boneList.append(bone.name)
else: # mode == 'EDIT':
for bone in arm.edit_bones:
boneList.append(bone.name)
return boneList
def getAllModifiers():
"""get list of all modifiers"""
modifierList = []
for obj in bpy.data.objects:
for mod in obj.modifiers:
modifierList.append(mod.name)
return modifierList
def getAllShapeKeys():
"""get list of all shape keys"""
shapeKeyNamesList = []
for key_grp in bpy.data.shape_keys:
for key in key_grp.key_blocks:
shapeKeyNamesList.append(key.name)
return shapeKeyNamesList
def getAllVertexGroups():
"""get list of all vertex groups"""
vrtx_grp_names_list = []
for obj in bpy.data.objects:
for vrtGrp in obj.vertex_groups:
vrtx_grp_names_list.append(vrtGrp.name)
return vrtx_grp_names_list
def getAllParticleNames():
"""get list of all particle systems"""
particlesNamesList = []
for obj in bpy.data.objects:
for particle_system in obj.particle_systems:
particlesNamesList.append(particle_system.name)
return particlesNamesList
def getAllParticleSettingsNames():
"""get list of all particle settings"""
particlesNamesList = []
for par in bpy.data.particles:
particlesNamesList.append(par.name)
return particlesNamesList
def getAllUvMaps():
uvNamesList = []
for obj in bpy.data.objects:
if obj.type != 'MESH':
continue
for uv in obj.data.uv_layers:
uvNamesList.append(uv)
return uvNamesList
def getAllColorAttributes():
colorAttributesList = []
for obj in bpy.data.objects:
if obj.type != 'MESH':
continue
for color_attribute in obj.data.color_attributes:
colorAttributesList.append(color_attribute)
return colorAttributesList
def getAllAttributes():
attributesList = []
for obj in bpy.data.objects:
if obj.type != 'MESH':
continue
for color_attribute in obj.data.color_attributes:
attributesList.append(color_attribute)
return attributesList
def getAllDataNames():
"""get list of all data"""
dataList = []
for obj in bpy.data.objects:
if obj.data is not None:
dataList.append(obj.data.name)
return dataList
@@ -0,0 +1,300 @@
import bpy
from bpy.types import PoseBone, EditBone
from .. import __package__ as base_package
def trim_string(string, size):
return string[size[0]:max(0, len(string)-size[1])]
def get_renaming_list(context):
scene = context.scene
renaming_list = []
switch_edit_mode = False
selection_only = scene.renaming_only_selection
obj_list = context.selected_objects.copy() if selection_only is True else list(bpy.data.objects).copy()
if scene.renaming_sorting:
if scene.renaming_object_types == 'BONE':
sort_enum = scene.renaming_sort_bone_enum
else:
sort_enum = scene.renaming_sort_enum
if sort_enum == 'SELECTION':
obj_list = get_ordered_selection_objects()
elif sort_enum == 'X':
obj_list = get_sorted_objects_x(obj_list)
elif sort_enum == 'Y':
obj_list = get_sorted_objects_y(obj_list)
else: # scene.renaming_sort_enum == 'Z':
obj_list = get_sorted_objects_z(obj_list)
if scene.renaming_sort_reverse:
obj_list.reverse()
if scene.renaming_object_types == 'OBJECT':
for obj in obj_list:
if obj in obj_list and obj.type in scene.renaming_object_types_specified:
renaming_list.append(obj)
elif scene.renaming_object_types == 'DATA':
for obj in obj_list:
if obj.data not in renaming_list:
renaming_list.append(obj.data)
elif scene.renaming_object_types == 'MATERIAL':
if selection_only:
for obj in context.selected_objects:
for mat in obj.material_slots:
if mat is not None and mat.name != '':
renaming_list.append(bpy.data.materials[mat.name])
else:
renaming_list = list(bpy.data.materials)
elif scene.renaming_object_types == 'IMAGE':
renaming_list = list(bpy.data.images)
elif scene.renaming_object_types == 'BONE':
old_mode = context.mode
if selection_only:
selection_and_active = context.selected_objects.copy()
if context.object not in selection_and_active:
selection_and_active.append(context.object)
if old_mode == 'OBJECT':
error_msg = "Renaming only selected Bones is only supported for EDIT and POSE mode by now."
return None, None, error_msg
elif old_mode == 'POSE':
selected_bones = context.selected_pose_bones.copy()
else: # if old_mode == 'EDIT_ARMATURE'
selected_bones = context.selected_editable_bones.copy()
switch_edit_mode = True
armatures = []
for obj in selection_and_active:
if obj.type == 'ARMATURE':
armatures.append(obj.data)
for selected_bone in selected_bones:
for arm in armatures:
if old_mode == 'POSE':
name = selected_bone.name
for bone in arm.bones:
if name == bone.name:
new_bone = PoseBone(arm.bones[name])
renaming_list.append(new_bone)
else: # old_mode == 'EDIT_ARMATURE':
for bone in arm.edit_bones:
if selected_bone == bone:
new_bone = EditBone(selected_bone)
renaming_list.append(new_bone)
else: # if selection_only == False
for arm in bpy.data.armatures:
if old_mode == 'EDIT_ARMATURE':
for bone in arm.edit_bones:
new_bone = EditBone(bone)
renaming_list.append(new_bone)
else: # old_mode == 'POSE' or old_mode == 'OBJECT'
for bone in arm.bones:
new_bone = PoseBone(bone)
renaming_list.append(new_bone)
elif scene.renaming_object_types == 'COLLECTION':
if bpy.context.space_data.type == 'OUTLINER' and selection_only is True:
selected_collections = [c for c in context.selected_ids if c.bl_rna.identifier == "Collection"]
for col in selected_collections:
renaming_list.append(col)
else:
renaming_list = list(bpy.data.collections)
elif scene.renaming_object_types == 'SHAPEKEYS':
if selection_only:
for obj in context.selected_objects:
for shape in obj.data.shape_keys.key_blocks:
renaming_list.append(shape)
else: # selection_only == False:
for key_grp in bpy.data.shape_keys:
for key in key_grp.key_blocks:
renaming_list.append(key)
elif scene.renaming_object_types == 'MODIFIERS':
if selection_only:
for obj in context.selected_objects:
for mod in obj.modifiers:
renaming_list.append(mod)
else: # selection_only == False:
for obj in bpy.data.objects:
for mod in obj.modifiers:
renaming_list.append(mod)
elif context.scene.renaming_object_types == 'VERTEXGROUPS':
if selection_only:
for obj in context.selected_objects:
for vtx in obj.vertex_groups:
renaming_list.append(vtx)
else:
for obj in bpy.data.objects:
for vtx in obj.vertex_groups:
renaming_list.append(vtx)
elif context.scene.renaming_object_types == 'PARTICLESYSTEM':
if selection_only:
for obj in context.selected_objects:
for particles in obj.particle_systems:
renaming_list.append(particles)
else:
for obj in bpy.data.objects:
for particles in obj.particle_systems:
renaming_list.append(particles)
elif context.scene.renaming_object_types == 'PARTICLESETTINGS':
for particles in bpy.data.particles:
renaming_list.append(particles)
elif context.scene.renaming_object_types == 'UVMAPS':
for obj in obj_list:
if obj.type != 'MESH':
continue
for uv in obj.data.uv_layers:
renaming_list.append(uv)
elif context.scene.renaming_object_types == 'COLORATTRIBUTES':
for obj in obj_list:
if obj.type != 'MESH':
continue
for color_attribute in obj.data.color_attributes:
renaming_list.append(color_attribute)
elif context.scene.renaming_object_types == 'ATTRIBUTES':
for obj in obj_list:
if obj.type != 'MESH':
continue
for attribute in obj.data.attributes:
renaming_list.append(attribute)
elif scene.renaming_object_types == 'ACTIONS':
if selection_only:
obj_list = context.selected_objects.copy()
for obj in obj_list:
ad = obj.animation_data
if ad:
if ad.action:
renaming_list.append(obj.animation_data.action)
for t in ad.nla_tracks:
for s in t.strips:
renaming_list.append(s.action)
else:
renaming_list = list(bpy.data.actions)
# renaming_list.sort(key=lambda x: x.name, reverse=False)
return renaming_list, switch_edit_mode, None
def call_renaming_popup(context):
prefs = context.preferences.addons[base_package].preferences
if prefs.renamingPanel_showPopup:
bpy.ops.wm.call_panel(name="POPUP_PT_popup")
return
def call_info_popup(context):
bpy.ops.wm.call_panel(name="POPUP_PT_info")
return
def call_error_popup(context):
bpy.ops.wm.call_panel(name="POPUP_PT_error")
return
# Function to get the global X location of an object
def get_global_x(obj):
return obj.matrix_world.to_translation().x
# Function to get the global X location of an object
def get_global_y(obj):
return obj.matrix_world.to_translation().y
def get_global_z(obj):
return obj.matrix_world.to_translation().z
def get_ordered_selection_objects():
tagged_objects = []
for o in bpy.data.objects:
order_index = o.get("selection_order", -1)
if order_index >= 0:
tagged_objects.append((order_index, o))
tagged_objects = sorted(tagged_objects, key=lambda item: item[0])
return [o for i, o in tagged_objects]
def get_sorted_objects_x(objects):
# Sort objects by their global X location
sorted_objects = sorted(objects, key=get_global_x)
return sorted_objects
def get_sorted_objects_y(objects):
# Sort objects by their global X location
sorted_objects = sorted(objects, key=get_global_y)
return sorted_objects
def get_sorted_objects_z(objects):
# Sort objects by their global X location
sorted_objects = sorted(objects, key=get_global_z)
return sorted_objects
def clear_order_flag(obj):
try:
del obj["selection_order"]
except KeyError:
pass
def update_selection_order():
if not bpy.context.selected_objects:
for o in bpy.data.objects:
clear_order_flag(o)
return
selection_order = get_ordered_selection_objects()
idx = 0
for o in selection_order:
if not o.select_get():
selection_order.remove(o)
clear_order_flag(o)
else:
o["selection_order"] = idx
# Hackish way to prevent unwanted keyframing of custom property.
# Setting custom properties non-animatable is not possible yet, see:
# https://projects.blender.org/blender/blender/issues/113506
if o.animation_data and o.animation_data.action:
fcurves = o.animation_data.action.fcurves
for fcurve in fcurves:
if fcurve.data_path == '["selection_order"]':
fcurves.remove(fcurve)
idx += 1
for o in bpy.context.selected_objects:
if o not in selection_order:
o["selection_order"] = len(selection_order)
selection_order.append(o)
@@ -0,0 +1,60 @@
import re
import bpy
from .renaming_operators import switch_to_edit_mode
from ..operators.renaming_utilities import get_renaming_list, call_renaming_popup, call_error_popup
from ..variable_replacer.variable_replacer import VariableReplacer
class VIEW3D_OT_search_and_replace(bpy.types.Operator):
bl_idname = "renaming.search_replace"
bl_label = "Search and Replace"
bl_description = "replaces parts in the object names"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
wm = context.scene
# get list of objects to be renamed
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
searchName = wm.renaming_search
msg = wm.renaming_messages # variable to save messages
VariableReplacer.reset()
if len(renaming_list) > 0:
for entity in renaming_list: # iterate over all objects that are to be renamed
if entity is not None:
if searchName != '':
oldName = entity.name
searchReplaced = VariableReplacer.replaceInputString(context, wm.renaming_search, entity)
replaceReplaced = VariableReplacer.replaceInputString(context, wm.renaming_replace, entity)
if not wm.renaming_useRegex:
if wm.renaming_matchcase:
new_name = str(entity.name).replace(searchReplaced, replaceReplaced)
entity.name = new_name
msg.add_message(oldName, entity.name)
else:
replaceSearch = re.compile(re.escape(searchReplaced), re.IGNORECASE)
new_name = replaceSearch.sub(replaceReplaced, entity.name)
entity.name = new_name
msg.add_message(oldName, entity.name)
else: # Use regex
# pattern = re.compile(re.escape(searchName))
new_name = re.sub(searchReplaced, replaceReplaced, str(entity.name))
entity.name = new_name
msg.add_message(oldName, entity.name)
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,90 @@
import re
import bpy
from .renaming_operators import switch_to_edit_mode
from ..operators.renaming_utilities import get_renaming_list, call_error_popup
from ..variable_replacer.variable_replacer import VariableReplacer
class VIEW3D_OT_naming(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
def invoke(self, context, event):
return self.execute(context)
def execute(self, context):
VariableReplacer.reset()
return
class VIEW3D_OT_search_and_select(VIEW3D_OT_naming):
bl_idname = "renaming.search_select"
bl_label = "Search and Select"
bl_description = "Select Object By Name"
bl_options = {'REGISTER', 'UNDO'}
def invoke(self, context, event):
return super().invoke(context, event)
def execute(self, context):
super().execute(context)
wm = context.scene
# get list of objects to be selected
selectionList = []
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
searchName = wm.renaming_search
msg = wm.renaming_messages # variable to save messages
if len(renaming_list) > 0:
for entity in renaming_list: # iterate over all objects that are to be renamed
if entity is not None and searchName != '':
entityName = entity.name
searchReplaced = VariableReplacer.replaceInputString(context, searchName, entity)
if wm.renaming_matchcase:
if entityName.find(searchReplaced) >= 0:
selectionList.append(entity)
msg.add_message("selected", entityName)
else:
if re.search(searchReplaced, entityName, re.IGNORECASE):
selectionList.append(entity)
if str(wm.renaming_object_types) == 'OBJECT':
# set to object mode
if bpy.context.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
for obj in selectionList:
obj.select_set(True)
elif str(wm.renaming_object_types) == 'BONE':
# print("SELECTION LIST: " + str(selectionList))
if bpy.context.mode == 'POSE':
bpy.ops.pose.select_all(action='DESELECT')
for bone in selectionList:
bone.select = True
elif bpy.context.mode == 'EDIT_ARMATURE':
bpy.ops.armature.select_all(action='DESELECT')
for bone in selectionList:
# print("EDIT Bone: " + str(bone))
bone.select = True
bone.select_head = True
bone.select_tail = True
# call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,37 @@
import bpy
from .renaming_operators import switch_to_edit_mode
from ..operators.renaming_utilities import get_renaming_list, trim_string, call_renaming_popup, call_error_popup
class VIEW3D_OT_trim_string(bpy.types.Operator):
bl_idname = "renaming.trim_string"
bl_label = "Trim String"
bl_description = "Deletes the in the trim size specified amount of characters at the start or the end of object names"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
wm = context.scene
renaming_list, switch_edit_mode, errMsg = get_renaming_list(context)
if errMsg is not None:
error_msg = wm.renaming_error_messages
error_msg.add_message(errMsg)
call_error_popup(context)
return {'CANCELLED'}
msg = wm.renaming_messages
if len(renaming_list) > 0:
for entity in renaming_list:
if entity is not None:
old_name = entity.name
new_name = trim_string(entity.name, wm.renaming_trim_indices)
entity.name = new_name
msg.add_message(old_name, entity.name)
call_renaming_popup(context)
if switch_edit_mode:
switch_to_edit_mode(context)
return {'FINISHED'}
@@ -0,0 +1,30 @@
import bpy
from . import renaming_keymap
from . import renaming_preferences
from .renaming_preferences import update_panel_category
classes = (
renaming_preferences.VIEW3D_OT_renaming_preferences,
renaming_keymap.REMOVE_OT_hotkey,
renaming_keymap.BUTTON_OT_change_key,
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
# update addon categories
update_panel_category(None, bpy.context)
renaming_keymap.add_keymap()
def unregister():
renaming_keymap.remove_keymap()
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
@@ -0,0 +1,122 @@
import bpy
from .. import __package__ as base_package
keymaps_items_dict = {
"Renaming Popup": ['wm.call_panel', 'VIEW3D_PT_tools_renaming_panel', '3D View Generic', 'VIEW_3D', 'WINDOW',
'F2', 'PRESS', True, False, True
],
"Suffix/Prefix Popup": ['wm.call_panel', 'VIEW3D_PT_tools_type_suffix', '3D View Generic', 'VIEW_3D', 'WINDOW',
'F2', 'PRESS', True, True, False
],
"Renaming Popup Outliner": ['wm.call_panel', 'VIEW3D_PT_tools_renaming_panel',
'Outliner', 'OUTLINER', 'WINDOW',
'F2', 'PRESS', True, False, False
]
}
class BUTTON_OT_change_key(bpy.types.Operator):
"""UI button to assign a new key to an addon hotkey"""
bl_idname = "rename.key_selection_button"
bl_label = "Press the button you want to assign to this operation."
bl_options = {'REGISTER', 'INTERNAL'}
property_prefix: bpy.props.StringProperty()
def __init__(self):
self.prefs = None
self.my_event = ''
def invoke(self, context, event):
prefs = context.preferences.addons[base_package].preferences
self.prefs = prefs
setattr(prefs, f'{self.property_prefix}_type', "NONE")
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def modal(self, context, event):
self.my_event = 'NONE'
if event.type and event.value == 'RELEASE': # Apply
self.my_event = event.type
setattr(self.prefs, f'{self.property_prefix}_type', self.my_event)
self.execute(context)
return {'FINISHED'}
return {'RUNNING_MODAL'}
def execute(self, context):
self.report({'INFO'},
"Key change: " + bpy.types.Event.bl_rna.properties['type'].enum_items[self.my_event].name)
return {'FINISHED'}
def add_keymap():
km = bpy.context.window_manager.keyconfigs.addon.keymaps.new(name="Window")
prefs = bpy.context.preferences.addons[base_package].preferences
kmi = km.keymap_items.new(idname='wm.call_panel', type=prefs.renaming_panel_type, value='PRESS',
ctrl=prefs.renaming_panel_ctrl, shift=prefs.renaming_panel_shift,
alt=prefs.renaming_panel_alt)
add_key_to_keymap('VIEW3D_PT_tools_renaming_panel', kmi, km, active=prefs.renaming_panel_active)
kmi = km.keymap_items.new(idname='wm.call_panel', type=prefs.renaming_suf_pre_type, value='PRESS',
ctrl=prefs.renaming_suf_pre_ctrl, shift=prefs.renaming_suf_pre_shift,
alt=prefs.renaming_suf_pre_alt)
add_key_to_keymap('VIEW3D_PT_tools_type_suffix', kmi, km, active=prefs.renaming_suf_pre_active)
def add_key_to_keymap(idname, kmi, km, active=True):
""" Add ta key to the appropriate keymap """
kmi.properties.name = idname
kmi.active = active
def remove_key(context, idname, properties_name):
"""Removes addon hotkeys from the keymap"""
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps['Window']
for kmi in km.keymap_items:
if kmi.idname == idname and kmi.properties.name == properties_name:
km.keymap_items.remove(kmi)
def remove_keymap():
"""Removes keys from the keymap. Currently, this is only called when unregistering the addon. """
# only works for menus and pie menus
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps['Window']
for kmi in km.keymap_items:
if hasattr(kmi.properties, 'name') and kmi.properties.name in ['VIEW3D_PT_tools_renaming_panel',
'VIEW3D_PT_tools_type_suffix']:
km.keymap_items.remove(kmi)
class REMOVE_OT_hotkey(bpy.types.Operator):
"""Tooltip"""
bl_idname = "rename.remove_hotkey"
bl_label = "Remove hotkey"
bl_description = "Remove hotkey"
bl_options = {'REGISTER', 'INTERNAL'}
idname: bpy.props.StringProperty()
properties_name: bpy.props.StringProperty()
property_prefix: bpy.props.StringProperty()
def execute(self, context):
remove_key(context, self.idname, self.properties_name)
prefs = context.preferences.addons[base_package].preferences
setattr(prefs, f'{self.property_prefix}_type', "NONE")
setattr(prefs, f'{self.property_prefix}_ctrl', False)
setattr(prefs, f'{self.property_prefix}_shift', False)
setattr(prefs, f'{self.property_prefix}_alt', False)
return {'FINISHED'}
@@ -0,0 +1,390 @@
import bpy
import textwrap
from bpy.props import (
EnumProperty,
StringProperty,
)
from .renaming_keymap import remove_key
from .. import __package__ as base_package
from ..ui.renaming_panels import VIEW3D_PT_tools_renaming_panel, VIEW3D_PT_tools_type_suffix
def label_multiline(context, text, parent):
chars = int(context.region.width / 7) # 7 pix on 1 character
wrapper = textwrap.TextWrapper(width=chars)
text_lines = wrapper.wrap(text=text)
for text_line in text_lines:
parent.label(text=text_line)
def add_key(km, idname, properties_name, button_assignment_type, button_assignment_ctrl, button_assignment_shift,
button_assignment_alt, button_assignment_active):
kmi = km.keymap_items.new(idname=idname, type=button_assignment_type, value='PRESS',
ctrl=button_assignment_ctrl, shift=button_assignment_shift, alt=button_assignment_alt)
kmi.properties.name = properties_name
kmi.active = button_assignment_active
def update_key(context, operation, operator_name, property_prefix):
# This functions gets called when the hotkey assignment is updated in the preferences
wm = context.window_manager
km = wm.keyconfigs.addon.keymaps["Window"]
prefs = context.preferences.addons[base_package].preferences
# Remove previous key assignment
remove_key(context, operation, operator_name)
add_key(km, operation, operator_name, getattr(prefs, f'{property_prefix}_type'),
getattr(prefs, f'{property_prefix}_ctrl'), getattr(prefs, f'{property_prefix}_shift'),
getattr(prefs, f'{property_prefix}_alt'), getattr(prefs, f'{property_prefix}_active'))
def update_renaming_key(self, context):
update_key(context, 'wm.call_panel', "VIEW3D_PT_tools_renaming_panel", "renaming_panel")
def update_suf_pre_key(self, context):
update_key(context, 'wm.call_panel', "VIEW3D_PT_tools_type_suffix", "renaming_suf_pre")
def update_panel_category(self, context):
"""Update panel tab for collider tools"""
panels = [
VIEW3D_PT_tools_renaming_panel,
VIEW3D_PT_tools_type_suffix,
]
for panel in panels:
try:
bpy.utils.unregister_class(panel)
except:
print('Could not register panel')
prefs = context.preferences.addons[base_package].preferences
panel.bl_category = prefs.renaming_category
bpy.utils.register_class(panel)
return
def toggle_suffix_prefix_panel(self, context):
if self.renaming_show_suffix_prefix_panel:
bpy.utils.register_class(VIEW3D_PT_tools_type_suffix)
else:
bpy.utils.unregister_class(VIEW3D_PT_tools_type_suffix)
return
# addon Preferences
class VIEW3D_OT_renaming_preferences(bpy.types.AddonPreferences):
"""Contains the blender addon preferences"""
# this must match the addon name, use 'base_package'
# when defining this in a submodule of a python package.
bl_idname = base_package
bl_options = {'REGISTER'}
prefs_tabs: EnumProperty(items=(('UI', "General", "General Settings"),
('KEYMAPS', "Keymaps", "Keymaps"),
('SUPPORT', "Support & Donation", "Support")),
default='UI')
renaming_category: StringProperty(name="Category",
description="Defines in which category of the tools panel the simple renaming "
"panel is listed",
default='Rename', update=update_panel_category)
renaming_separator: StringProperty(
name="Separator",
description="Defines the separator between different operations",
default='_',
)
renamingPanel_showPopup: bpy.props.BoolProperty(
name="Show Popup",
description="Enable or Disable Popup",
default=True,
)
renamingPanel_useObjectOrder: bpy.props.BoolProperty(
name="Use Selection Order",
description="Use the order of selection when renaming objects",
default=True,
)
numerate_start_number: bpy.props.IntProperty(
name="Numerate Start",
description="Defines the first number for iterating objects. E.g., 1 means that the first object will be "
"named [objectname]001",
default=1,
)
numerate_digits: bpy.props.IntProperty(
name="Digits",
description="Defines digits used for numerating. Number 1 with digits 3 would result in 001",
default=3,
)
numerate_step: bpy.props.IntProperty(
name="Numerate Step",
description="Defines the steps between numbers. E.g., 1 results in 1, 2, 3, a step size ot two results in 1,3,5",
default=1,
)
renaming_stringHigh: StringProperty(
name="High",
description="",
default="high",
)
renaming_stringLow: StringProperty(
name="Low",
description="",
default='low',
)
renaming_stringCage: StringProperty(
name="Cage",
description="",
default='cage',
)
renaming_user1: StringProperty(
name="User 1",
description="",
default='',
)
renaming_user2: StringProperty(
name="User 2",
description="",
default='',
)
renaming_user3: StringProperty(
name="User 3",
description="",
default='',
)
renaming_show_suffix_prefix_panel: bpy.props.BoolProperty(
name="Prefix/Suffix by Type Panel",
description="Enable or disable the Prefix/Suffix by Type Panel",
default=True,
update=toggle_suffix_prefix_panel)
regex_Mesh: bpy.props.StringProperty(
name="Naming Regex",
description="",
default='r"^[A-Za-z_]"',
)
materialRegex: bpy.props.StringProperty(
name="Material Regex",
description="",
default='r"^[A-Za-z_](_mat)?$""',
)
props_general = [
"renaming_category",
"renamingPanel_showPopup",
"renaming_show_suffix_prefix_panel",
"renamingPanel_useObjectOrder",
]
props_naming = [
"renaming_separator",
"numerate_digits",
]
props_numerate = [
"numerate_start_number",
"numerate_step",
]
props_user_variables = [
"renaming_stringLow",
"renaming_stringHigh",
"renaming_stringCage",
"renaming_user1",
"renaming_user2",
"renaming_user3"
]
renaming_panel_type: bpy.props.StringProperty(
name="Renaming Popup",
default="F2",
update=update_renaming_key
)
renaming_panel_ctrl: bpy.props.BoolProperty(
name="Ctrl",
default=True,
update=update_renaming_key
)
renaming_panel_shift: bpy.props.BoolProperty(
name="Shift",
default=True,
update=update_renaming_key
)
renaming_panel_alt: bpy.props.BoolProperty(
name="Alt",
default=False,
update=update_renaming_key
)
renaming_panel_active: bpy.props.BoolProperty(
name="Active",
default=True,
update=update_renaming_key
)
renaming_suf_pre_type: bpy.props.StringProperty(
name="Renaming Popup",
default="F2",
update=update_suf_pre_key
)
renaming_suf_pre_ctrl: bpy.props.BoolProperty(
name="Ctrl",
default=True,
update=update_suf_pre_key
)
renaming_suf_pre_shift: bpy.props.BoolProperty(
name="Shift",
default=False,
update=update_suf_pre_key
)
renaming_suf_pre_alt: bpy.props.BoolProperty(
name="Alt",
default=True,
update=update_suf_pre_key
)
renaming_suf_pre_active: bpy.props.BoolProperty(
name="Active",
default=True,
update=update_suf_pre_key
)
def keymap_ui(self, layout, title, property_prefix, id_name, properties_name):
box = layout.box()
split = box.split(align=True, factor=0.5)
col = split.column()
# Is hotkey active checkbox
row = col.row(align=True)
row.prop(self, f'{property_prefix}_active', text="")
row.label(text=title)
# Button to assign the key assignments
col = split.column()
row = col.row(align=True)
key_type = getattr(self, f'{property_prefix}_type')
text = (
bpy.types.Event.bl_rna.properties['type'].enum_items[key_type].name
if key_type != 'NONE'
else 'Press a key'
)
op = row.operator("rename.key_selection_button", text=text)
op.property_prefix = property_prefix
# row.prop(self, f'{property_prefix}_type', text="")
op = row.operator("rename.remove_hotkey", text="", icon="X")
op.idname = id_name
op.properties_name = properties_name
op.property_prefix = property_prefix
row = col.row(align=True)
row.prop(self, f'{property_prefix}_ctrl')
row.prop(self, f'{property_prefix}_shift')
row.prop(self, f'{property_prefix}_alt')
def draw(self, context):
"""
simple preference UI to define custom inputs and user preferences
"""
layout = self.layout
row = layout.row(align=True)
row.prop(self, "prefs_tabs", expand=True)
# General settings regarding renaming
if self.prefs_tabs == 'UI':
for propName in self.props_general:
row = layout.row()
row.prop(self, propName)
box = layout.box()
row = box.row()
row.label(text='Naming')
for propName in self.props_naming:
row = box.row()
row.prop(self, propName)
box = layout.box()
row = box.row()
row.label(text='Numerate')
for propName in self.props_numerate:
row = box.row()
row.prop(self, propName)
box = layout.box()
row = box.row()
row.label(text='User Variables')
for propName in self.props_user_variables:
row = box.row()
row.prop(self, propName)
# Settings regarding the keymap
if self.prefs_tabs == 'KEYMAPS':
self.keymap_ui(layout, 'Renaming Panel', 'renaming_panel',
'wm.call_panel', "VIEW3D_PT_tools_renaming_panel")
self.keymap_ui(layout, 'Renaming Sub/Prefix', 'renaming_suf_pre',
'wm.call_panel', "VIEW3D_PT_tools_type_suffix")
elif self.prefs_tabs == 'SUPPORT':
text = "Support me developing great tools!"
label_multiline(
context=context,
text=text,
parent=layout
)
# Donations
box = layout.box()
text = "Consider supporting the development of this addon with a donation!"
label_multiline(
context=context,
text=text,
parent=box
)
col = box.column(align=True)
row = col.row()
row.operator("wm.url_open", text="Gumroad",
icon="URL").url = "https://weisl.gumroad.com/l/simple_renaming"
row = col.row()
row.operator("wm.url_open", text="Superhive Market",
icon="URL").url = "https://superhivemarket.com/products/simple-renaming"
row = col.row()
row.operator("wm.url_open", text="PayPal Donation",
icon="URL").url = "https://www.paypal.com/donate?hosted_button_id=JV7KRF77TY78A"
# Cross Promotion
box = layout.box()
text = "Explore my other Blender Addons designed for more efficient game asset workflows!"
label_multiline(
context=context,
text=text,
parent=box
)
col = box.column(align=True)
row = col.row()
row.operator("wm.url_open", text="Simple Collider",
icon="URL").url = "https://superhivemarket.com/products/simple-collider"
row = col.row()
row.operator("wm.url_open", text="Simple Camera Manager",
icon="URL").url = "https://superhivemarket.com/products/simple-camera-manager"
row = col.row()
row.label(text='Support & Feedback')
row = col.row()
row.operator("wm.url_open", text="Join Discord", icon="URL").url = "https://discord.gg/VRzdcFpczm"
@@ -0,0 +1,51 @@
import bpy
from .info_messages import RENAMING_MESSAGES, WarningError_MESSAGES, INFO_MESSAGES
from .renaming_panels import VIEW3D_PT_tools_renaming_panel, VIEW3D_PT_tools_type_suffix, VIEW3D_OT_SetVariable, \
VIEW3D_OT_RenamingPopupOperator, OBJECT_MT_suffix_prefix_presets, AddPresetRenamingPresets
from .renaming_panels import panel_func
from .renaming_popup import VIEW3D_PT_renaming_popup, VIEW3D_PT_info_popup, VIEW3D_PT_error_popup
from .renaming_variables import RENAMING_MT_variableMenu, VIEW3D_OT_inputVariables
from .ui_helpers import PREFERENCES_OT_open_addon
classes = (
RENAMING_MT_variableMenu,
VIEW3D_OT_inputVariables,
VIEW3D_PT_error_popup,
VIEW3D_PT_info_popup,
VIEW3D_PT_renaming_popup,
OBJECT_MT_suffix_prefix_presets,
AddPresetRenamingPresets,
VIEW3D_PT_tools_renaming_panel,
VIEW3D_PT_tools_type_suffix,
VIEW3D_OT_SetVariable,
VIEW3D_OT_RenamingPopupOperator,
PREFERENCES_OT_open_addon,
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.VIEW3D_PT_tools_type_suffix.prepend(panel_func)
id_store = bpy.types.Scene
id_store.renaming_messages = RENAMING_MESSAGES()
id_store.renaming_error_messages = WarningError_MESSAGES()
id_store.renaming_info_messages = INFO_MESSAGES()
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
id_store = bpy.types.Scene
del id_store.renaming_messages
del id_store.renaming_error_messages
del id_store.renaming_info_messages
@@ -0,0 +1,55 @@
class MESSAGE:
"""messages parent class"""
message = []
@classmethod
def add_message(cls):
return
@classmethod
def get_messages(cls):
return cls.message
@classmethod
def print_all(cls):
print("Print All " + str(list(cls.message)))
return
@classmethod
def clear(cls):
cls.message = []
@classmethod
def draw(cls, context):
return
class INFO_MESSAGES(MESSAGE):
"""Custom info messages"""
@classmethod
def add_message(cls, assetName, message='', obType=False, obIcon=False):
message_dict = {'assetName': assetName, 'message': message, 'obType': obType, 'obIcon': obIcon}
cls.message.append(message_dict)
return
class WarningError_MESSAGES(MESSAGE):
"""Custom error warning messages"""
@classmethod
def add_message(cls, message='', isError=False):
message_dict = {'message': message, 'isError': isError}
cls.message.append(message_dict)
return
class RENAMING_MESSAGES(MESSAGE):
"""Custom renaming messages"""
message = []
@classmethod
def add_message(cls, oldName, new_name=None, obType=False, obIcon=False, warning=False):
message_dict = {'oldName': oldName, 'new_name': new_name, 'obType': obType, 'obIcon': obIcon, 'warning': warning}
cls.message.append(message_dict)
return
@@ -0,0 +1,359 @@
import bpy
from bl_operators.presets import AddPresetBase
from bpy.props import StringProperty
from bpy.types import Operator, Menu
from ..ui.renaming_variables import RENAMING_MT_variableMenu
# Selected objects are renamed directly
types_selected = ('OBJECT', 'ADDOBJECTS', 'BONE')
# Components of the selected objects are renamed
types_of_selected = (
'MATERIAL', 'DATA', 'VERTEXGROUPS', 'PARTICLESYSTEM', 'SHAPEKEYS', 'MODIFIERS', 'UVMAPS',
'COLORATTRIBUTES', 'ATTRIBUTES', 'ACTIONS')
def draw_renaming_panel(layout, context):
scene = context.scene
row = layout.row(align=True)
row.label(text="Target")
row = layout.row(align=True)
row.prop(scene, "renaming_object_types", text="")
# SELECTED
if str(scene.renaming_object_types) == 'OBJECT':
layout.prop(scene, "renaming_object_types_specified", expand=True)
if str(scene.renaming_object_types) in types_of_selected:
layout.prop(scene, "renaming_only_selection", text="Only Of Selected Objects")
elif str(scene.renaming_object_types) in types_selected:
layout.prop(scene, "renaming_only_selection", text="Only Selected")
elif str(scene.renaming_object_types) == 'COLLECTION':
if bpy.context.space_data.type == 'OUTLINER':
row = layout.row(align=True)
row.prop(scene, "renaming_only_selection", text="Only Selected")
else:
col = layout.column(align=True)
row = col.row(align=True)
row.enabled = False
row.prop(scene, "renaming_only_selection", text="Only Selected")
row = col.row(align=True)
row.enabled = False
row.label(text="Open from Outliner", icon="ERROR")
box = layout
# Sorting
if str(scene.renaming_object_types) not in ['COLLECTION', 'IMAGE']:
col = box.column(align=True)
col.prop(scene, "renaming_sorting")
if scene.renaming_sorting:
if str(scene.renaming_object_types) == 'BONE':
col.prop(scene, "renaming_sort_bone_enum", expand=True)
else:
col.prop(scene, "renaming_sort_enum", expand=True)
col.prop(scene, "renaming_sort_reverse")
layout.separator(type='LINE')
layout.label(text="Rename")
# NEW NAME
col = layout.column(align=True)
col.prop(scene, "renaming_use_enumerate")
row = col.row(align=True)
split = row.split(factor=0.6, align=True)
split.prop(scene, "renaming_new_name", text='')
split = split.split(factor=0.75, align=True)
split.prop(scene, "renaming_numerate", text='')
split.operator("object.renaming_set_variable", text="@").inputBox = "new_name"
row = col.row()
row.operator("renaming.name_replace", icon="FORWARD")
# SEARCH REPLACE
layout.separator()
layout.label(text="Search and Replace")
split = layout.split(factor=0.5, align=True)
col_a = split.column(align=True)
col_b = split.column(align=True)
row = col_a.row(align=True)
row.prop(scene, "renaming_useRegex")
row = col_b.row(align=True)
row.enabled = not scene.renaming_useRegex
row.prop(scene, "renaming_matchcase")
col = layout.column(align=True)
split = col.split(factor=0.9, align=True)
split.prop(scene, "renaming_search", text='Search')
split.operator("object.renaming_set_variable", text="@").inputBox = "search"
split = col.split(factor=0.9, align=True)
split.prop(scene, "renaming_replace", text='Replace')
split.operator("object.renaming_set_variable", text="@").inputBox = "replace"
if scene.renaming_object_types == 'BONE':
if context.mode == 'POSE' or context.mode == 'EDIT_ARMATURE':
row = layout.row(align=True)
row.operator("renaming.search_select", icon="RESTRICT_SELECT_OFF")
elif scene.renaming_object_types == 'OBJECT':
row = layout.row(align=True)
row.operator("renaming.search_select", icon="RESTRICT_SELECT_OFF")
row = layout.row(align=True)
row.operator("renaming.search_replace", icon="FILE_REFRESH")
###############################################
layout.separator()
layout.label(text="Add Prefix and Suffix")
# REFIX SUFFIX
col = layout.column(align=True)
split = col.split(factor=0.9, align=True)
split.prop(scene, "renaming_prefix", text='')
split.operator("object.renaming_set_variable", text="@").inputBox = "prefix"
col.operator("renaming.add_prefix", icon="REW")
col = layout.column(align=True)
split = col.split(factor=0.9, align=True)
split.prop(scene, "renaming_suffix", text='')
split.operator("object.renaming_set_variable", text="@").inputBox = "suffix"
col.operator("renaming.add_suffix", icon="FF")
###############################################
layout.separator()
layout.label(text="Trim")
# TRIM
col = layout.column(align=True)
col.prop(scene, "renaming_trim_indices",index=0,text="First")
col.prop(scene, "renaming_trim_indices",index=1,text="Last")
row = layout.row(align=True)
row.operator("renaming.trim_string", icon="X")
###############################################
layout.separator()
layout.label(text="Other")
row = layout.row(align=True)
row.operator("renaming.numerate", icon="LINENUMBERS_ON")
if str(scene.renaming_object_types) in ('DATA', 'OBJECT', 'ADDOBJECTS'):
layout.separator()
layout.label(text="Data Name")
col = layout.column(align=True)
split = col.split(factor=0.9, align=True)
split.prop(scene, "renaming_suffix_prefix_data_02", text='')
split.operator("object.renaming_set_variable", text="@").inputBox = "dataFromObj"
col.operator("renaming.data_name_from_obj", icon="MOD_DATA_TRANSFER")
def panel_func(self, context):
layout = self.layout
row = layout.row(align=True)
row.menu('OBJECT_MT_suffix_prefix_presets', text=OBJECT_MT_suffix_prefix_presets.bl_label)
row.operator(AddPresetRenamingPresets.bl_idname, text="", icon='ADD')
row.operator(AddPresetRenamingPresets.bl_idname, text="", icon='REMOVE').remove_active = True
class VIEW3D_PT_tools_renaming_panel(bpy.types.Panel):
"""Creates a renaming Panel"""
bl_label = "Simple Renaming"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Rename"
def draw_header(self, context):
layout = self.layout
row = layout.row(align=True)
row.operator("wm.url_open", text="", icon='HELP').url = "https://weisl.github.io/renaming_overview/"
addon_name = get_addon_name()
op = row.operator("preferences.rename_addon_search", text="", icon='PREFERENCES')
op.addon_name = addon_name
op.prefs_tabs = 'UI'
def draw(self, context):
layout = self.layout
draw_renaming_panel(layout, context)
# needed for adding direct link to settings
def get_addon_name():
return "Simple Renaming"
# addon Panel
class VIEW3D_PT_tools_type_suffix(bpy.types.Panel):
"""Creates a renaming Panel"""
bl_label = "Prefix/Suffix by Type"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Rename"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
scene = context.scene
layout = self.layout
layout.prop(scene, "type_pre_sub_only_selection", text="Only Selected Objects")
layout.prop(scene, "renaming_suffix_prefix_type", expand=True)
# layout.prop(scene, "renaming_suffix_prefix_types_specified")
if scene.renaming_suffix_prefix_type == "PRE":
layout.label(text="Add Type Prefix")
else:
layout.label(text="Add Type Suffix")
split = layout.split()
col = split.column()
row = col.row()
row.prop(scene, "renaming_suffix_prefix_empty", text="")
row.operator("renaming.add_suffix_prefix_by_type", text="Empties").option = 'empty'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_geometry", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Meshes").option = 'mesh'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_material", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Materials").option = 'material'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_curve", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Curves").option = 'curve'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_armature", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Armatures").option = 'armature'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_lattice", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Lattices").option = 'lattice'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_data", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Data").option = 'data'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_surfaces", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Surfaces").option = 'surface'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_cameras", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Cameras").option = 'camera'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_lights", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Lights").option = 'light'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_collection", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Collections").option = 'collection'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_text", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Texts").option = 'text'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_gpencil", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Grease Pencil").option = 'gpencil'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_metaball", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Metaballs").option = 'metaball'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_bone", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Bones").option = 'bone'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_speakers", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Speakers").option = 'speakers'
row = col.row()
row.prop(scene, "renaming_suffix_prefix_lightprops", text="")
row.operator('renaming.add_suffix_prefix_by_type', text="Light Probes").option = 'lightprops'
row = col.row()
row.operator('renaming.add_suffix_prefix_by_type', text="Rename All").option = 'all'
class VIEW3D_OT_SetVariable(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.renaming_set_variable"
bl_label = "Simple Object Operator"
inputBox: StringProperty()
def execute(self, context):
context.scene.renaming_inputContext = self.inputBox
bpy.ops.wm.call_menu(name=RENAMING_MT_variableMenu.bl_idname)
return {'FINISHED'}
class VIEW3D_OT_RenamingPopupOperator(bpy.types.Operator):
bl_idname = "renaming.f_popup_operator"
bl_label = "Simple Renaming"
my_float: bpy.props.FloatProperty(name="Some Floating Point")
my_bool: bpy.props.BoolProperty(name="Toggle Option")
my_string: bpy.props.StringProperty(name="String Value")
def execute(self, context):
print("Dialog Runs")
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
class OBJECT_MT_suffix_prefix_presets(Menu):
bl_label = "Type Presets"
preset_subdir = "scene/display"
preset_operator = "script.execute_preset"
draw = Menu.draw_preset
class AddPresetRenamingPresets(AddPresetBase, Operator):
"""Add an Object Display Preset"""
bl_idname = "renaming.sufpreadd_presets"
bl_label = "Add Renaming Preset"
preset_menu = "OBJECT_MT_suffix_prefix_presets"
# variable used for all preset values
preset_defines = [
"scene = bpy.context.scene"
]
# properties to store in the preset
preset_values = [
"scene.renaming_suffix_prefix_empty",
"scene.renaming_suffix_prefix_geometry",
"scene.renaming_suffix_prefix_material",
"scene.renaming_suffix_prefix_curve",
"scene.renaming_suffix_prefix_armature",
"scene.renaming_suffix_prefix_lattice",
"scene.renaming_suffix_prefix_data",
"scene.renaming_suffix_prefix_surfaces",
"scene.renaming_suffix_prefix_cameras",
"scene.renaming_suffix_prefix_lights",
"scene.renaming_suffix_prefix_collection",
"scene.renaming_suffix_prefix_text",
"scene.renaming_suffix_prefix_gpencil",
"scene.renaming_suffix_prefix_metaball",
"scene.renaming_suffix_prefix_bone",
"scene.renaming_suffix_prefix_speakers",
"scene.renaming_suffix_prefix_lightprops",
]
# where to store the preset
preset_subdir = "scene/display"
@@ -0,0 +1,137 @@
import bpy
class VIEW3D_PT_error_popup(bpy.types.Panel):
"""Tooltip"""
bl_idname = "POPUP_PT_error"
bl_label = "Renaming Info"
bl_space_type = "VIEW_3D"
bl_region_type = "WINDOW"
bl_ui_units_x = 30
def draw(self, context):
layout = self.layout
box = layout.box()
wm = context.scene
messages = wm.renaming_error_messages
if len(messages.message) <= 0:
box.label(text="Unknown Error", icon="INFO")
else:
for msg in messages.message:
if msg is not None:
row = box.row(align=False)
# row.alignment = 'EXPAND'
if msg['isError']:
row.label(text=str('Error'), icon='ERROR')
row = box.row(align=False)
row.label(text=str(msg['message']), icon='ERROR')
else:
row.label(text=str('Warning'), icon='ERROR')
row = box.row(align=False)
row.label(text=str(msg['message']), icon='CANCEL')
messages.clear()
return
class VIEW3D_PT_info_popup(bpy.types.Panel):
"""Tooltip"""
bl_idname = "POPUP_PT_info"
bl_label = "Renaming Info"
bl_space_type = "VIEW_3D"
bl_region_type = "WINDOW"
bl_ui_units_x = 30
def draw(self, context):
layout = self.layout
box = layout.box()
wm = context.scene
infos = wm.renaming_info_messages
if len(infos.message) <= 0:
box.label(text="No Objects Validated", icon="INFO")
else:
i = 0
for msg in infos.message:
if msg is not None:
if msg['message'] is not None:
row = box.row(align=True)
row.alignment = 'EXPAND'
if msg['obType'] is not False and msg['obIcon'] is not False:
row.label(text=str(msg['obType']), icon=msg['obIcon'])
# row.label(text = str(msg['obType']), icon = 'INFO')
else:
row.label(text=str(wm.renaming_object_types))
row.label(text=str(msg['assetName']), icon='FILE_TICK')
row.label(text=str(msg['oldName']))
i += 1
infos.clear()
class VIEW3D_PT_renaming_popup(bpy.types.Panel):
"""Tooltip"""
bl_idname = "POPUP_PT_popup"
bl_label = "Renaming Info"
bl_space_type = "VIEW_3D"
bl_region_type = "WINDOW"
bl_ui_units_x = 30
def draw(self, context):
wm = context.scene
layout = self.layout
box = layout.box()
if len(wm.renaming_messages.message) <= 0:
box.label(text="No Objects Renamed", icon="INFO")
else:
i = 0
for msg in wm.renaming_messages.message:
if msg is not None:
if not msg['warning']:
if (msg['new_name'] is not None and msg['oldName'] is not None) and msg['oldName'] != msg[
'new_name']:
if i == 0:
row = box.row(align=True)
row.alignment = 'EXPAND'
row.label(text="Object Type")
row.label(text="New Name")
row.label(text="Old Name")
box.separator(type='LINE')
row = box.row(align=True)
row.alignment = 'EXPAND'
if msg['obType'] is not False and msg['obIcon'] is not False:
row.label(text=str(msg['obType']), icon=msg['obIcon'])
else:
row.label(text=str(wm.renaming_object_types))
row.label(text=str(msg['new_name']), icon='FILE_TICK')
row.label(text=str(msg['oldName']))
i += 1
else: # if msg['warning'] == True
if msg['new_name'] is not None and msg['oldName'] is not None:
box.label(text="Warning", icon="ERROR")
box.label(text=" " + "Name: " + str(msg['oldName']))
box.label(text=" " + msg['warning'])
else:
box.label(text="Warning", icon="ERROR")
box.label(text=" " + msg['warning'])
if i == 0:
box.label(text="No Objects Renamed", icon="INFO")
wm.renaming_messages.clear()
@@ -0,0 +1,103 @@
import bpy
from bpy.props import StringProperty
class RENAMING_MT_variableMenu(bpy.types.Menu):
bl_label = "Renaming Variables"
bl_idname = "MENU_MT_renaming_variables"
def draw(self, context):
layout = self.layout
wm = bpy.context.scene
layout.operator("object.renaming_multivariables", text="RANDOM").renaming_variables = "RANDOM"
layout.operator("object.renaming_multivariables", text="NUMBER").renaming_variables = "NUMBER"
layout.separator()
layout.operator("object.renaming_multivariables", text="LOW").renaming_variables = "LOW"
layout.operator("object.renaming_multivariables", text="HIGH").renaming_variables = "HIGH"
layout.operator("object.renaming_multivariables", text="CAGE").renaming_variables = "CAGE"
layout.separator()
layout.operator("object.renaming_multivariables", text='FILE').renaming_variables = 'FILE'
layout.operator("object.renaming_multivariables", text="TIME").renaming_variables = "TIME"
layout.operator("object.renaming_multivariables", text="DATE").renaming_variables = "DATE"
layout.separator()
layout.operator("object.renaming_multivariables", text="USER1").renaming_variables = "USER1"
layout.operator("object.renaming_multivariables", text="USER2").renaming_variables = "USER2"
layout.operator("object.renaming_multivariables", text="USER3").renaming_variables = "USER3"
if wm.renaming_object_types == 'OBJECT':
layout.separator()
layout.operator("object.renaming_multivariables", text="PARENT").renaming_variables = "PARENT"
layout.operator("object.renaming_multivariables", text="DATA").renaming_variables = "DATA"
layout.operator("object.renaming_multivariables", text="ACTIVE").renaming_variables = "ACTIVE"
layout.operator("object.renaming_multivariables", text='FILE').renaming_variables = 'OBJECT'
layout.operator("object.renaming_multivariables", text="TYPE").renaming_variables = "TYPE"
layout.operator("object.renaming_multivariables", text="COLLECTION").renaming_variables = "COLLECTION"
class VIEW3D_OT_inputVariables(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.renaming_multivariables"
bl_label = "Simple Object Operator"
renaming_variables: StringProperty()
def execute(self, context):
# wm = context.scene
# replaceName = VariableReplacer.replaceInputString(context, wm.renaming_new_name)
# The print function works fine
renaming_variables = self.renaming_variables
# print (self.renaming_variables)
name_var = ""
# print('T changed to ', renaming_variables)
if renaming_variables == 'FILE':
name_var = "@f"
if renaming_variables == 'OBJECT':
name_var = "@o"
if renaming_variables == "HIGH":
name_var = "@h"
if renaming_variables == "LOW":
name_var = "@l"
if renaming_variables == "CAGE":
name_var = "@b"
if renaming_variables == "DATE":
name_var = "@d"
if renaming_variables == "ACTIVE":
name_var = "@a"
if renaming_variables == "USER1":
name_var = "@u1"
if renaming_variables == "USER2":
name_var = "@u2"
if renaming_variables == "USER3":
name_var = "@u3"
if renaming_variables == "TIME":
name_var = "@i"
if renaming_variables == "TYPE":
name_var = "@t"
if renaming_variables == "PARENT":
name_var = "@p"
if renaming_variables == "DATA":
name_var = "@m"
if renaming_variables == "NUMBER":
name_var = "@n"
if renaming_variables == "RANDOM":
name_var = "@r"
if renaming_variables == "COLLECTION":
name_var = "@c"
scn = context.scene
if scn.renaming_inputContext == 'new_name':
context.scene.renaming_new_name += str(name_var)
if scn.renaming_inputContext == 'prefix':
context.scene.renaming_prefix += str(name_var)
if scn.renaming_inputContext == 'suffix':
context.scene.renaming_suffix += str(name_var)
if scn.renaming_inputContext == 'search':
context.scene.renaming_search += str(name_var)
if scn.renaming_inputContext == 'replace':
context.scene.renaming_replace += str(name_var)
return {'FINISHED'}
@@ -0,0 +1,38 @@
import bpy
from .. import __package__ as base_package
class PREFERENCES_OT_open_addon(bpy.types.Operator):
"""Tooltip"""
bl_idname = "preferences.rename_addon_search"
bl_label = "Open Addon preferences"
addon_name: bpy.props.StringProperty()
prefs_tabs: bpy.props.StringProperty()
def execute(self, context):
bpy.ops.screen.userpref_show()
bpy.context.preferences.active_section = 'ADDONS'
bpy.data.window_managers["WinMan"].addon_search = self.addon_name
prefs = context.preferences.addons[base_package].preferences
prefs.prefs_tabs = self.prefs_tabs
import addon_utils
mod = addon_utils.addons_fake_modules.get('collider_tools')
# mod is None the first time the operation is called :/
if mod:
mod.bl_info['show_expanded'] = True
# Find User Preferences area and redraw it
for window in bpy.context.window_manager.windows:
for area in window.screen.areas:
if area.type == 'USER_PREFERENCES':
area.tag_redraw()
bpy.ops.preferences.addon_expand(module=self.addon_name)
return {'FINISHED'}
@@ -0,0 +1,189 @@
import random
import re
import string
import time
import bpy
from .. import __package__ as base_package
def generate_random_string(string_length=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(string_length))
class VariableReplacer:
"""This class is responsible for the custom variables"""
addon_prefs = None
entity = None
number = 1
digits = 3
step = 1
start_number = 0
@classmethod
def reset(cls):
"""reset all values to initial state"""
prefs = bpy.context.preferences.addons[base_package].preferences
start_number = prefs.numerate_start_number
numerate_step = prefs.numerate_step
numerate_digits = prefs.numerate_digits
# print("reset = " + str(start_number))
cls.step = numerate_step
cls.digits = numerate_digits
cls.start_number = start_number
cls.number = 0
@classmethod
def replaceInputString(cls, context, inputText, entity):
"""Replace custom variables with the according string"""
wm = context.scene
cls.addon_prefs = context.preferences.addons[base_package].preferences
# System and Global Values #
inputText = re.sub(r'@f', cls.getfileName(context), inputText) # file name
inputText = re.sub(r'@d', cls.getDateName(), inputText) # date
inputText = re.sub(r'@i', cls.getTimeName(), inputText) # time
inputText = re.sub(r'@r', cls.getRandomString(), inputText)
# UserStrings #
inputText = re.sub(r'@h', cls.get_high_variable(), inputText) # high
inputText = re.sub(r'@l', cls.get_low_variable(), inputText) # low
inputText = re.sub(r'@b', cls.get_cage_variable(), inputText) # cage
inputText = re.sub(r'@u1', cls.getuser1(), inputText)
inputText = re.sub(r'@u2', cls.getuser2(), inputText)
inputText = re.sub(r'@u3', cls.getuser3(), inputText)
# GetScene #
inputText = re.sub(r'@a', cls.getActive(context), inputText) # active object
inputText = re.sub(r'@n', cls.getNumber(), inputText)
if wm.renaming_object_types == 'OBJECT':
# Objects
inputText = re.sub(r'@o', cls.getObject(entity), inputText) # object
inputText = re.sub(r'@t', cls.getType(entity), inputText) # type
inputText = re.sub(r'@p', cls.getParent(entity), inputText) # parent
inputText = re.sub(r'@m', cls.getData(entity), inputText) # data
inputText = re.sub(r'@c', cls.getCollection(entity), inputText) # collection
# IMAGES #
if wm.renaming_object_types == 'IMAGE':
inputText = re.sub(r'@r', 'RESOLUTION', inputText)
inputText = re.sub(r'@i', 'FILETYPE', inputText)
return inputText
@staticmethod
def getRandomString():
"""Generate a Random String with the length of 6"""
return generate_random_string(6)
@classmethod
def get_high_variable(cls):
"""Get High Poly identifier string"""
return cls.addon_prefs.renaming_stringHigh
@classmethod
def get_low_variable(cls):
"""Get Low Poly identifier string"""
return cls.addon_prefs.renaming_stringLow
@classmethod
def get_cage_variable(cls):
"""Get baking cage identifier string"""
return cls.addon_prefs.renaming_stringCage
@classmethod
def getuser1(cls):
return cls.addon_prefs.renaming_user1
@classmethod
def getuser2(cls):
return cls.addon_prefs.renaming_user2
@classmethod
def getuser3(cls):
return cls.addon_prefs.renaming_user3
@classmethod
def getPrefString(cls, suffixString):
method = getattr(cls, suffixString, lambda: "Undefined variable")
return method()
@classmethod
def getNumber(cls):
new_nr = cls.number
step = cls.step
start_num = cls.start_number
nr = str('{num:{fill}{width}}'.format(num=(new_nr * step) + start_num, fill='0', width=cls.digits))
cls.number = new_nr + 1
return nr
@classmethod
def getfileName(cls, context):
scn = context.scene
if bpy.data.is_saved:
filename = bpy.path.display_name(context.blend_data.filepath)
else:
filename = "UNSAVED"
# scn.renaming_messages.add_message(oldName, entity.name)
return filename
@classmethod
def getDateName(cls):
t = time.localtime()
t = time.mktime(t)
return time.strftime("%d%b%Y", time.gmtime(t))
@classmethod
def getTimeName(cls):
t = time.localtime()
t = time.mktime(t)
return time.strftime("%H:%M", time.gmtime(t))
@classmethod
def getActive(cls, context):
if context.object is None:
return ""
else:
return context.object.name
# OBJECTS
@classmethod
def getObject(cls, entity):
obj_name = entity.name
return obj_name
@classmethod
def getType(cls, entity):
return str(entity.type)
@classmethod
def getParent(cls, entity):
if entity.parent is not None:
return str(entity.parent.name)
else:
return entity.name
@classmethod
def getData(cls, entity):
if entity.data is not None:
return str(entity.data.name)
else:
return entity.name
@classmethod
def getCollection(cls, entity):
collectionew_names = ""
for collection in bpy.data.collections:
collection_objects = collection.objects
if entity.name in collection.objects and entity in collection_objects[:]:
collectionew_names += collection.name
return collectionew_names