├── LICENSE ├── README.md ├── README_Neltulz_Smart_Frame_Selection.html ├── __init__.py ├── addonPreferences.py ├── keymaps.py ├── mainOt.py ├── miscFunc.py ├── miscLay.py ├── miscOt.py ├── panels.py └── properties.py /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neltulz_Smart_Frame_Selection 2 | A quick way to frame selected, or frame all if nothing is selected. 3 | 4 | [View Complete README File](https://www.logichaos.com/neltulz_blender_addons/neltulz_smart_frame_selection/README_Neltulz_Smart_Frame_Selection) -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | bl_info = { 2 | "name" : "Neltulz - Smart Frame", 3 | "author" : "Neil V. Moore", 4 | "description" : 'More ways to "Frame Selection" when pressing the keyboard shortcut', 5 | "blender" : (2, 80, 0), 6 | "version" : (1, 0, 16), 7 | "location" : "View3D", 8 | "warning" : "", 9 | "category" : "Generic", 10 | "tracker_url": "mailto:neilvmoore@gmail.com", 11 | "wiki_url": "https://www.logichaos.com/neltulz_blender_addons/neltulz_smart_frame_selection/README_Neltulz_Smart_Frame_Selection" 12 | } 13 | 14 | # ----------------------------------------------------------------------------- 15 | # Import Classes and/or functions 16 | # ----------------------------------------------------------------------------- 17 | 18 | import bpy 19 | 20 | #scene properties 21 | from . properties import ntzsf_scene_props 22 | 23 | #main operator 24 | from . mainOt import VIEW3D_OT_ntzsf_smart_frame 25 | from . mainOt import VIEW3D_OT_ntzsf_isolate 26 | from . mainOt import VIEW3D_OT_ntzsf_frame_and_isolate 27 | from . mainOt import VIEW3D_OT_ntzsf_viewport_to_origin 28 | 29 | #misc operators 30 | from . miscOt import VIEW3D_OT_ntzsf_add_obj_to_excluded_isolate_objs 31 | from . miscOt import VIEW3D_OT_ntzsf_del_obj_from_excluded_isolate_objs 32 | from . miscOt import VIEW3D_OT_ntzsf_refresh_excluded_isolate_objs 33 | from . miscOt import VIEW3D_OT_ntzsf_clear_all_excluded_isolate_objs 34 | from . miscOt import VIEW3D_OT_ntzsf_convert_obj_to_template 35 | from . miscOt import VIEW3D_OT_ntzsf_refresh_template_objs 36 | from . miscOt import VIEW3D_OT_ntzsf_untemplate_objs 37 | from . miscOt import VIEW3D_OT_ntzsf_toggle_template 38 | from . miscOt import VIEW3D_OT_ntzsf_template_specific_obj 39 | from . miscOt import VIEW3D_OT_ntzsf_untemplate_specific_obj 40 | from . miscOt import VIEW3D_OT_ntzsf_clear_all_template_objs 41 | from . miscOt import VIEW3D_OT_ntzsf_change_template_selection_state 42 | from . miscOt import VIEW3D_OT_ntzsf_sel_obj_by_name 43 | 44 | #addon preferences operator 45 | from . addonPreferences import VIEW3D_OT_ntzsf_addon_prefs 46 | 47 | #panels 48 | from . panels import VIEW3D_PT_ntzsf_frame_options 49 | from . panels import VIEW3D_PT_ntzsf_isolate_options 50 | from . panels import VIEW3D_PT_ntzsf_tmpl_options 51 | from . panels import VIEW3D_PT_ntzsf_options 52 | from . panels import VIEW3D_PT_ntzsf_sb_panel 53 | 54 | #keymaps 55 | from . import keymaps 56 | 57 | PendingDeprecationWarning 58 | 59 | bDebugModeActive = False 60 | if bDebugModeActive: 61 | print("##################################################################################################################################################################") 62 | print("REMINDER: DEBUG MODE ACTIVE") 63 | print("##################################################################################################################################################################") 64 | 65 | # ----------------------------------------------------------------------------- 66 | # Store classes in List so that they can be easily registered/unregistered 67 | # ----------------------------------------------------------------------------- 68 | 69 | classes = ( 70 | #scene properties 71 | ntzsf_scene_props, 72 | 73 | #main operator 74 | VIEW3D_OT_ntzsf_smart_frame, 75 | VIEW3D_OT_ntzsf_isolate, 76 | VIEW3D_OT_ntzsf_frame_and_isolate, 77 | VIEW3D_OT_ntzsf_viewport_to_origin, 78 | 79 | #misc operators 80 | VIEW3D_OT_ntzsf_add_obj_to_excluded_isolate_objs, 81 | VIEW3D_OT_ntzsf_del_obj_from_excluded_isolate_objs, 82 | VIEW3D_OT_ntzsf_refresh_excluded_isolate_objs, 83 | VIEW3D_OT_ntzsf_clear_all_excluded_isolate_objs, 84 | VIEW3D_OT_ntzsf_convert_obj_to_template, 85 | VIEW3D_OT_ntzsf_refresh_template_objs, 86 | VIEW3D_OT_ntzsf_untemplate_objs, 87 | VIEW3D_OT_ntzsf_toggle_template, 88 | VIEW3D_OT_ntzsf_template_specific_obj, 89 | VIEW3D_OT_ntzsf_untemplate_specific_obj, 90 | VIEW3D_OT_ntzsf_clear_all_template_objs, 91 | VIEW3D_OT_ntzsf_change_template_selection_state, 92 | VIEW3D_OT_ntzsf_sel_obj_by_name, 93 | 94 | #addon preferences operator 95 | VIEW3D_OT_ntzsf_addon_prefs, 96 | 97 | #panels 98 | VIEW3D_PT_ntzsf_frame_options, 99 | VIEW3D_PT_ntzsf_isolate_options, 100 | VIEW3D_PT_ntzsf_tmpl_options, 101 | VIEW3D_PT_ntzsf_options, 102 | VIEW3D_PT_ntzsf_sb_panel, 103 | ) 104 | 105 | # ----------------------------------------------------------------------------- 106 | # Register classes from the classes list 107 | # ----------------------------------------------------------------------------- 108 | 109 | addon_keymaps = [] 110 | 111 | #vscode pme workaround from iceythe (part 2 of 2) 112 | def _reg(): 113 | pme = bpy.utils._preferences.addons['pie_menu_editor'].preferences 114 | for pm in pme.pie_menus: 115 | if pm.key != 'NONE': 116 | pm.register_hotkey() 117 | #END vscode pme workaround (part 2 of 2) 118 | 119 | def register(): 120 | 121 | from bpy.utils import register_class 122 | for cls in classes: 123 | register_class(cls) 124 | 125 | # update panel name 126 | addonPrefs = bpy.context.preferences.addons[__name__].preferences 127 | addonPreferences.update_panel(addonPrefs, bpy.context) 128 | 129 | #add keymaps from keymaps.py 130 | keymaps.ntzsfRegKM(addon_keymaps) 131 | 132 | #add property group to the scene 133 | bpy.types.Scene.ntzSmFrm = bpy.props.PointerProperty(type=ntzsf_scene_props) 134 | 135 | #vscode pme workaround from iceythe (part 1 of 2) 136 | #must be appended to def register() so that it is the last thing that executes 137 | if bDebugModeActive: 138 | if not bpy.app.timers.is_registered(_reg): 139 | bpy.app.timers.register(_reg, first_interval=1) 140 | #END vscode pme workaround (part 1 of 2) 141 | 142 | def unregister(): 143 | from bpy.utils import unregister_class 144 | for cls in reversed(classes): 145 | unregister_class(cls) 146 | 147 | #remove keymaps 148 | keymaps.ntzsfUnregKM(addon_keymaps) 149 | 150 | if __name__ == "__main__": 151 | register() 152 | 153 | # test call 154 | bpy.ops.view3d.ntzsf_smart_frame() -------------------------------------------------------------------------------- /addonPreferences.py: -------------------------------------------------------------------------------- 1 | # Update "Tab Category Name" inspired by "Meta-Androcto's" "Edit Mesh Tools" Add-on 2 | # recommended by "cytoo" 3 | 4 | import bpy 5 | from . panels import VIEW3D_PT_ntzsf_sb_panel 6 | from . import miscLay 7 | 8 | from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty) 9 | from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup) 10 | 11 | # Define Panel classes for updating 12 | panels = ( 13 | VIEW3D_PT_ntzsf_sb_panel, 14 | ) 15 | 16 | 17 | 18 | def update_panel(self, context): 19 | 20 | sidebarPanelSize_PropVal = context.preferences.addons[__package__].preferences.sidebarPanelSize 21 | category_PropVal = context.preferences.addons[__package__].preferences.category 22 | popupAndPiePanelSize_PropVal = context.preferences.addons[__package__].preferences.popupAndPiePanelSize 23 | 24 | message = "Neltulz - Smart Frame: Updating Panel locations has failed" 25 | try: 26 | for panel in panels: 27 | if "bl_rna" in panel.__dict__: 28 | bpy.utils.unregister_class(panel) 29 | 30 | #Whatever the user typed into the text box in the add-ons settings, set that as the addon's tab category name 31 | for panel in panels: 32 | 33 | if sidebarPanelSize_PropVal == "HIDE": 34 | panel.bl_category = "" 35 | panel.bl_region_type = "WINDOW" 36 | 37 | else: 38 | if self.sidebarPanelSize == "DEFAULT": 39 | panel.bUseCompactSidebarPanel = False 40 | else: 41 | panel.bUseCompactSidebarPanel = True 42 | 43 | panel.bl_category = category_PropVal 44 | panel.bl_region_type = "UI" 45 | 46 | if self.popupAndPiePanelSize == "DEFAULT": 47 | panel.bUseCompactPopupAndPiePanel = False 48 | else: 49 | panel.bUseCompactPopupAndPiePanel = True 50 | 51 | bpy.utils.register_class(panel) 52 | 53 | except Exception as e: 54 | print("\n[{}]\n{}\n\nError:\n{}".format(__package__, message, e)) 55 | pass 56 | 57 | 58 | class VIEW3D_OT_ntzsf_addon_prefs(AddonPreferences): 59 | # this must match the addon name, use '__package__' 60 | # when defining this in a submodule of a python package. 61 | bl_idname = __package__ 62 | 63 | navTabs_List = [ 64 | ("UILAY", "UI Layout", "", "", 0), 65 | ("FRAME", "Frame", "", "", 1), 66 | ("ISO", "Isolate", "", "", 2), 67 | ("TMPL", "Template", "", "", 3), 68 | ] 69 | 70 | navTabs : EnumProperty ( 71 | items = navTabs_List, 72 | name = "Navigation Tabs", 73 | default = "UILAY" 74 | ) 75 | 76 | category: StringProperty( 77 | name="Tab Category", 78 | description="Choose a name for the category of the panel", 79 | default="Neltulz", 80 | update=update_panel, 81 | ) 82 | 83 | sidebarpanelSize_List = [ 84 | ("DEFAULT", "Default", "", "", 0), 85 | ("COMPACT", "Compact", "", "", 1), 86 | ("HIDE", "Hide", "", "", 2), 87 | ] 88 | 89 | popupAndPiePanelSize_List = [ 90 | ("DEFAULT", "Default", "", "", 0), 91 | ("COMPACT", "Compact", "", "", 1), 92 | ] 93 | 94 | sidebarPanelSize : EnumProperty ( 95 | items = sidebarpanelSize_List, 96 | name = "Sidebar Panel Size", 97 | description = "Sidebar Panel Size", 98 | default = "DEFAULT", 99 | update=update_panel, 100 | ) 101 | 102 | popupAndPiePanelSize : EnumProperty ( 103 | items = popupAndPiePanelSize_List, 104 | name = "Popup & Pie Panel Size", 105 | description = "Popup & Pie Panel Size", 106 | default = "COMPACT", 107 | update=update_panel, 108 | ) 109 | 110 | # ----------------------------------------------------------------------------- 111 | # Frame 112 | # ----------------------------------------------------------------------------- 113 | 114 | bUseSmoothFraming : BoolProperty ( 115 | name="Smoothly Frame", 116 | default = True, 117 | ) 118 | 119 | expandSelectedObjsInOutliner : BoolProperty ( 120 | name = "Expand Selected Objects in Outliner(s)", 121 | default = True, 122 | ) 123 | 124 | collapseUnselectedObjsInOutliner : BoolProperty ( 125 | name = 'Collapse Unselected Objects in Outliner(s)', 126 | description = 'Note: This is implemented very sloppily', 127 | default = False, 128 | ) 129 | 130 | calcZoomDistanceMethod_List = [ 131 | ("MIN", "Min", "Get the minimum length of the bounding box axes (or in the case of single vertice selection, only the closest vertice(s) will be framed)", "", 0), 132 | ("AVG", "Avg", "Get the average length of the bounding box axes (or in the case of single vertice selection, framing will be based on the average distance of all adjacent vertices. Some vertices may not be framed)", "", 1), 133 | ("MAX", "Max", "Get the maximum length of the bounding box axes (or in the case of single vertice selection: All adjacent vertices will be framed)", "", 2), 134 | ] 135 | 136 | 137 | calcZoomDistanceMethod : EnumProperty ( 138 | items = calcZoomDistanceMethod_List, 139 | name = "Zoom Distance Calculation Method", 140 | default = "AVG" 141 | ) 142 | 143 | frameObjTypeList = ["frameMesh", "frameCurve", "frameSurface", "frameMeta", "frameText", "frameGreasePen", "frameArmature", "frameLattice", "frameEmpty", "frameLight", "frameLightProbe", "frameCamera", "frameSpeaker"] 144 | 145 | frameObjTypeList2 = { 146 | 'MESH': 'frameMesh', 147 | 'CURVE': 'frameCurve', 148 | 'SURFACE': 'frameSurface', 149 | 'META': 'frameMeta', 150 | 'FONT': 'frameText', 151 | 'GPENCIL': 'frameGreasePen', 152 | 'ARMATURE': 'frameArmature', 153 | 'LATTICE': 'frameLattice', 154 | 'EMPTY': 'frameEmpty', 155 | 'LIGHT': 'frameLight', 156 | 'LIGHTPROBE': 'frameLightProbe', 157 | 'CAMERA': 'frameCamera', 158 | 'SPEAKER': 'frameSpeaker', 159 | } 160 | 161 | frameMesh : BoolProperty( 162 | name="Mesh", 163 | description="Frame Mesh (Default: True)", 164 | default = True 165 | ) 166 | 167 | frameCurve : BoolProperty( 168 | name="Curve", 169 | description="Frame Curve (Default: True)", 170 | default = True 171 | ) 172 | 173 | frameSurface : BoolProperty( 174 | name="Surface", 175 | description="Frame Surface (Default: True)", 176 | default = True 177 | ) 178 | 179 | frameMeta : BoolProperty( 180 | name="Meta", 181 | description="Frame Meta (Default: True)", 182 | default = True 183 | ) 184 | 185 | frameText : BoolProperty( 186 | name="Text", 187 | description="Frame Text (Default: True)", 188 | default = True 189 | ) 190 | 191 | frameGreasePen : BoolProperty( 192 | name="GreasePen", 193 | description="Frame GreasePen (Default: True)", 194 | default = True 195 | ) 196 | 197 | frameArmature : BoolProperty( 198 | name="Armature", 199 | description="Frame Armature (Default: True)", 200 | default = True 201 | ) 202 | 203 | frameLattice : BoolProperty( 204 | name="Lattice", 205 | description="Frame Lattice (Default: True)", 206 | default = True 207 | ) 208 | 209 | frameEmpty : BoolProperty( 210 | name="Empty", 211 | description="Frame Empty (Default: True)", 212 | default = True 213 | ) 214 | 215 | frameLight : BoolProperty( 216 | name="Light", 217 | description="Frame Light (Default: True)", 218 | default = False 219 | ) 220 | 221 | frameLightProbe : BoolProperty( 222 | name="LightProbe", 223 | description="Frame LightProbe (Default: True)", 224 | default = True 225 | ) 226 | 227 | frameCamera : BoolProperty( 228 | name="Camera", 229 | description="Frame Camera (Default: True)", 230 | default = True 231 | ) 232 | 233 | frameSpeaker : BoolProperty( 234 | name="Speaker", 235 | description="Frame Speaker (Default: True)", 236 | default = True 237 | ) 238 | 239 | useAllRegionsWhenFraming : BoolProperty( 240 | name="Use all Regions when Framing", 241 | description="When framing an object, all regions will frame the object. This is useful if you use Quad view. (Default: True)", 242 | default = True 243 | ) 244 | 245 | useAll3DAreasWhenFraming : BoolProperty( 246 | name="Use all 3D Areas when Framing", 247 | description="When framing an object, all 3D Areas will frame the object. This is useful if you use multiple 3D Views. (Default: True)", 248 | default = True 249 | ) 250 | 251 | #Updated by "Frame", "Isolate" and, "Frame & Isolate" operators at end of execute, and fetched by the operator on invoke 252 | use_zoomAdjust : BoolProperty (default=True) 253 | zoomAdjust : FloatProperty(default=0) 254 | 255 | 256 | maxVertAllowanceForZoomAdjust : IntProperty ( 257 | name="Total", 258 | description="Maximum number of vertices a mesh can have in order to to use Zoom Adjust. This is a performance setting. Setting this number too high can result in program slowness and instability. Recommended: 1 million or less", 259 | default = 1000000 260 | ) 261 | 262 | maxVertSelectionAllowanceForZoomAdjust : IntProperty ( 263 | name="Selected", 264 | description='Maximum number of vertices a mesh can have "Selected" in order to to use Zoom Adjust. This is a performance setting. Setting this number too high can result in program slowness and instability. Recommended: 10,000 or less', 265 | default = 10000 266 | ) 267 | 268 | # ----------------------------------------------------------------------------- 269 | # Isolate 270 | # ----------------------------------------------------------------------------- 271 | 272 | hideFloorOnIsolate : BoolProperty( 273 | name="Hide Floor on Isolate", 274 | description="Hides the floor when you isolate an object. (Default: True)", 275 | default = True 276 | ) 277 | 278 | hideAxesOnIsolate : BoolProperty( 279 | name="Hide Axes on Isolate", 280 | description="Hides the axes when you isolate an object. (Default: True)", 281 | default = True 282 | ) 283 | 284 | useExtremeHideOnIsolate : BoolProperty( 285 | name="Use Extreme Isolate (Use Caution)", 286 | description='Sets "Show in Viewports" to "False" to grant a super performance increase. Useful for adding objects to the scene and adjusting operator properties with minimal performance lag. (Default: False)', 287 | default = False 288 | ) 289 | 290 | # ----------------------------------------------------------------------------- 291 | # Template 292 | # ----------------------------------------------------------------------------- 293 | 294 | defaultTemplateSelectableState_List = [ 295 | ("UNSET", "Unset (Use Last Known)", "", "", 0), 296 | ("UNSELECTABLE", "Un-selectable", "", "RESTRICT_SELECT_ON", 1), 297 | ("SELECTABLE", "Selectable", "", "RESTRICT_SELECT_OFF", 2), 298 | ] 299 | 300 | defaultTemplateSelectableState : EnumProperty ( 301 | items = defaultTemplateSelectableState_List, 302 | name = "Default Template Selectable State", 303 | description = "Default Selectable Method for new Template Objects", 304 | default = "UNSELECTABLE" 305 | ) 306 | 307 | def draw(self, context): 308 | 309 | lay = self.layout.column(align=True) 310 | 311 | 312 | 313 | if self.sidebarPanelSize == "HIDE": 314 | bTabCatEnabled = False 315 | else: 316 | bTabCatEnabled = True 317 | 318 | navRow = lay.row(align=True) 319 | navRow.scale_y = 1.25 320 | navRow.prop(self, 'navTabs', expand=True) 321 | 322 | 323 | box = lay.box().column(align=True) 324 | 325 | labelJustify = "RIGHT" 326 | 327 | propJustify = "LEFT" 328 | 329 | if self.navTabs == "UILAY": 330 | propHeight = 1 331 | labelWidth = 7 332 | propWidth = 15 333 | 334 | miscLay.createProp(self, context, None, True, "Sidebar Panel", self, "sidebarPanelSize", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 335 | 336 | box.separator() 337 | 338 | miscLay.createProp(self, context, None, bTabCatEnabled, "Tab Category", self, "category", propHeight, labelWidth, propWidth, labelJustify, propJustify, "", True, False, box) 339 | 340 | box.separator() 341 | 342 | miscLay.createProp(self, context, None, True, "Popup & Pie Panel", self, "popupAndPiePanelSize", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 343 | 344 | elif self.navTabs == "FRAME": 345 | propHeight = 1 346 | labelWidth = 7 347 | propWidth = 15 348 | 349 | miscLay.createProp(self, context, None, True, "", self, "bUseSmoothFraming", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 350 | miscLay.createProp(self, context, None, True, "", self, "expandSelectedObjsInOutliner", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 351 | 352 | box.label(text="Experimental:") 353 | miscLay.createProp(self, context, None, self.expandSelectedObjsInOutliner, "", self, "collapseUnselectedObjsInOutliner", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 354 | 355 | 356 | box.separator() 357 | 358 | 359 | 360 | # calcZoomDistanceMethod prop 361 | #----------------------------------------------------------------------------------------------------------- 362 | row = box.row(align=True) 363 | 364 | col1MasterContainer = row.row(align=True) 365 | col1MasterContainer.alignment="EXPAND" 366 | col1MasterContainer.ui_units_x = labelWidth 367 | 368 | col1Container = col1MasterContainer.column(align=True) 369 | col1Container.alignment=labelJustify 370 | col1Container.scale_x = 1 371 | col1Container.scale_y = 0.75 372 | 373 | col1Container.separator(factor=0.75) 374 | col1Container.label(text='Calculate Zoom') 375 | 376 | col2MasterContainer = row.row(align=True) 377 | col2MasterContainer.alignment=propJustify 378 | 379 | col2Container = col2MasterContainer.column(align=True) 380 | col2Container.alignment=propJustify 381 | col2Container.ui_units_x = propWidth 382 | col2Container.scale_x = 100 383 | 384 | propRow = col2Container.row(align=True) 385 | propRow.prop(self, "calcZoomDistanceMethod", expand=True) 386 | 387 | box.separator() 388 | 389 | # When nothing is selected, frame: 390 | #----------------------------------------------------------------------------------------------------------- 391 | row = box.row(align=True) 392 | 393 | col1MasterContainer = row.row(align=True) 394 | col1MasterContainer.alignment="EXPAND" 395 | col1MasterContainer.ui_units_x = labelWidth 396 | 397 | col1Container = col1MasterContainer.column(align=True) 398 | col1Container.alignment=labelJustify 399 | col1Container.scale_x = 1 400 | col1Container.scale_y = 0.75 401 | 402 | col1Container.separator(factor=0.75) 403 | col1Container.label(text='When nothing is') 404 | col1Container.label(text='selected, frame:') 405 | 406 | col2MasterContainer = row.row(align=True) 407 | col2MasterContainer.alignment=propJustify 408 | 409 | col2Container = col2MasterContainer.column(align=True) 410 | col2Container.alignment=propJustify 411 | col2Container.ui_units_x = propWidth 412 | col2Container.scale_x = 100 413 | 414 | propGrid = col2Container.grid_flow(row_major=True, columns=2, align=True) 415 | 416 | for frameObjType in self.frameObjTypeList: 417 | propGrid.prop(self, frameObjType, expand=True, toggle=True) 418 | 419 | # When framing, use all: 420 | #----------------------------------------------------------------------------------------------------------- 421 | row = box.row(align=True) 422 | 423 | col1MasterContainer = row.row(align=True) 424 | col1MasterContainer.alignment="EXPAND" 425 | col1MasterContainer.ui_units_x = labelWidth 426 | 427 | col1Container = col1MasterContainer.column(align=True) 428 | col1Container.alignment=labelJustify 429 | col1Container.scale_x = 1 430 | col1Container.scale_y = 0.75 431 | 432 | col1Container.separator(factor=0.75) 433 | col1Container.label(text='When framing,') 434 | col1Container.label(text='use all:') 435 | 436 | col2MasterContainer = row.row(align=True) 437 | col2MasterContainer.alignment=propJustify 438 | 439 | col2Container = col2MasterContainer.column(align=True) 440 | col2Container.alignment=propJustify 441 | col2Container.ui_units_x = propWidth 442 | col2Container.scale_x = 100 443 | 444 | col2Container.separator(factor=1) 445 | 446 | propRow = col2Container.row(align=True) 447 | 448 | propRow.prop(self, "useAllRegionsWhenFraming", toggle=True, text="Regions") 449 | propRow.prop(self, "useAll3DAreasWhenFraming", toggle=True, text="3D Areas") 450 | 451 | # Max Allowable Total Verts: 452 | #----------------------------------------------------------------------------------------------------------- 453 | row = box.row(align=True) 454 | 455 | col1MasterContainer = row.row(align=True) 456 | col1MasterContainer.alignment="EXPAND" 457 | col1MasterContainer.ui_units_x = labelWidth 458 | 459 | col1Container = col1MasterContainer.column(align=True) 460 | col1Container.alignment=labelJustify 461 | col1Container.scale_x = 1 462 | col1Container.scale_y = 0.75 463 | 464 | col1Container.separator(factor=2.5) 465 | col1Container.label(text='Max Vert Limit') 466 | col1Container.label(text='for Zoom Adjust:') 467 | 468 | col2MasterContainer = row.row(align=True) 469 | col2MasterContainer.alignment=propJustify 470 | 471 | col2Container = col2MasterContainer.column(align=True) 472 | col2Container.alignment=propJustify 473 | col2Container.ui_units_x = propWidth 474 | col2Container.scale_x = 100 475 | 476 | col2Container.separator(factor=1) 477 | 478 | propRow = col2Container.column(align=True) 479 | 480 | propRow.prop(self, "maxVertAllowanceForZoomAdjust") 481 | propRow.prop(self, "maxVertSelectionAllowanceForZoomAdjust") 482 | 483 | 484 | 485 | 486 | 487 | elif self.navTabs == "ISO": 488 | propHeight = 1 489 | labelWidth = 7 490 | propWidth = 15 491 | 492 | floorAxesRow = box.row(align=True) 493 | 494 | labelRow = floorAxesRow.row(align=True) 495 | labelRow.scale_y = propHeight 496 | labelRow.alignment="EXPAND" 497 | labelRow.ui_units_x = labelWidth 498 | 499 | labelRow2 = labelRow.row(align=True) 500 | labelRow2.alignment=labelJustify 501 | labelRow2.scale_x = 1 502 | 503 | labelRow2.label(text='On Isolate, hide:') 504 | 505 | propRow = floorAxesRow.row(align=True) 506 | propRow.scale_x = 150 507 | propRow.ui_units_x = propWidth 508 | propRow.alignment = propJustify 509 | 510 | propRow.scale_y = propHeight 511 | 512 | propRow.prop(self, 'hideFloorOnIsolate', text="Floor", toggle=False, icon="MESH_GRID") 513 | 514 | propRow.prop(self, 'hideAxesOnIsolate', text="Axes", toggle=False, icon="EMPTY_AXIS") 515 | 516 | box.separator() 517 | 518 | 519 | miscLay.createProp(self, context, None, True, "", self, "useExtremeHideOnIsolate", propHeight, labelWidth, propWidth, labelJustify, propJustify, None, True, False, box) 520 | 521 | elif self.navTabs == "TMPL": 522 | propHeight = 1 523 | labelWidth = 7 524 | propWidth = 15 525 | 526 | # calcZoomDistanceMethod prop 527 | #----------------------------------------------------------------------------------------------------------- 528 | row = box.row(align=True) 529 | 530 | col1MasterContainer = row.row(align=True) 531 | col1MasterContainer.alignment="EXPAND" 532 | col1MasterContainer.ui_units_x = labelWidth 533 | 534 | col1Container = col1MasterContainer.column(align=True) 535 | col1Container.alignment=labelJustify 536 | col1Container.scale_x = 1 537 | col1Container.scale_y = 0.75 538 | 539 | col1Container.separator(factor=0.75) 540 | col1Container.label(text='Default Template') 541 | col1Container.label(text='Selectable State:') 542 | 543 | col2MasterContainer = row.row(align=True) 544 | col2MasterContainer.alignment=propJustify 545 | 546 | 547 | col2Container = col2MasterContainer.column(align=True) 548 | 549 | col2Container.separator(factor=1) 550 | 551 | col2Container.alignment=propJustify 552 | col2Container.ui_units_x = propWidth 553 | col2Container.scale_x = 100 554 | 555 | propRow = col2Container.row(align=True) 556 | 557 | propRow.prop(self, "defaultTemplateSelectableState", expand=False, text="") -------------------------------------------------------------------------------- /keymaps.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from . properties import ntzsf_scene_props 3 | 4 | # ----------------------------------------------------------------------------- 5 | # Keymaps (For Register) 6 | # ----------------------------------------------------------------------------- 7 | 8 | def ntzsfRegKM(addon_keymaps): 9 | 10 | wm = bpy.context.window_manager 11 | 12 | 13 | #------------------------------ 3D View ---------------------------------------------------------------------------- 14 | 15 | #create new keymap 16 | km = wm.keyconfigs.addon.keymaps.new(name="3D View", space_type="VIEW_3D") 17 | 18 | #Frame 19 | kmi = km.keymap_items.new("view3d.ntzsf_smart_frame", type = "F", ctrl=False, shift=False, alt=False, value = "PRESS") 20 | kmi.properties.tooltip = "Frame an object, selection of objects, vertice, edge, face, or when all else fails: frame everything" 21 | kmi.properties.frameSelection = True 22 | kmi.properties.isolateSelection = False 23 | kmi.properties.frameMethod = "SEL" 24 | 25 | #Isolate / Unhide Selection 26 | kmi = km.keymap_items.new("view3d.ntzsf_isolate", type = "F", ctrl=False, shift=True, alt=False, value = "PRESS") 27 | kmi.properties.tooltip = "Isolate an object, selection of objects, vertice, edge, face, or when all else fails: isolate everything" 28 | kmi.properties.frameSelection = False 29 | kmi.properties.isolateSelection = True 30 | kmi.properties.frameMethod = "SEL" 31 | 32 | #Frame & Isolate 33 | kmi = km.keymap_items.new("view3d.ntzsf_frame_and_isolate", type = "F", ctrl=True, shift=True, alt=False, value = "PRESS") 34 | kmi.properties.tooltip = "Frame and Isolate an object, selection of objects, vertices, edges, or faces, simultaneously, or when all else fails: everything" 35 | kmi.properties.frameSelection = True 36 | kmi.properties.isolateSelection = True 37 | kmi.properties.frameMethod = "SEL" 38 | 39 | #Viewport to Origin 40 | kmi = km.keymap_items.new("view3d.ntzsf_viewport_to_origin", type = "R", ctrl=True, shift=True, alt=False, value = "PRESS") 41 | kmi.properties.tooltip = "Move the viewport to the origin" 42 | kmi.properties.frameSelection = True 43 | kmi.properties.isolateSelection = False 44 | kmi.properties.frameMethod = "ORIGIN" 45 | 46 | #Template Object 47 | kmi = km.keymap_items.new("view3d.ntzsf_toggle_template", type = "T", ctrl=True, shift=True, alt=False, value = "PRESS") 48 | kmi.properties.tooltip = "Converts an object to a wireframe with click-through (unselectable) capability for reference purposes" 49 | 50 | #add list of keymaps 51 | addon_keymaps.append(km) 52 | 53 | def ntzsfUnregKM(addon_keymaps): 54 | # handle the keymap 55 | wm = bpy.context.window_manager 56 | for km in addon_keymaps: 57 | wm.keyconfigs.addon.keymaps.remove(km) 58 | # clear the list 59 | addon_keymaps.clear() -------------------------------------------------------------------------------- /mainOt.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import bmesh 3 | 4 | from . properties import ntzsf_scene_props 5 | from . import miscFunc 6 | 7 | from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty) 8 | from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup) 9 | 10 | # ----------------------------------------------------------------------------- 11 | # Main Addon Operator 12 | # ----------------------------------------------------------------------------- 13 | 14 | class opProps(): 15 | tooltip: bpy.props.StringProperty() 16 | 17 | wasInvoked : BoolProperty ( 18 | name="Operator was invoked", 19 | default = False 20 | ) 21 | 22 | invokeView : StringProperty ( 23 | name="Invoke View Operators", 24 | ) 25 | 26 | selModeAtBegin = (True, False, False) 27 | totalVertCount = 0 28 | totalNumVertsSel = 0 29 | 30 | frameMethod_List = [ 31 | ("SEL", "Selection", "", "", 0), 32 | ("ORIGIN", "Origin", "", "", 1), 33 | ] 34 | 35 | frameMethod : EnumProperty ( 36 | items=frameMethod_List, 37 | description="Frame Method", 38 | default="SEL", 39 | ) 40 | 41 | frameSelection : BoolProperty ( 42 | name="Frame Selection", 43 | description="Frame selected objects or verts, edges, and faces (Default: True)", 44 | default = True 45 | ) 46 | 47 | isolateSelection : BoolProperty ( 48 | name="Isolate Selection", 49 | description="Isolate Selection when Framing (Default: False)", 50 | default = False 51 | ) 52 | 53 | 54 | #fetched on invoke from addonPrefs 55 | use_zoomAdjust : BoolProperty ( 56 | name = "Use Zoom Adjust", 57 | description = "Use Zoom Adjust when framing objects, verts, edges, or faces", 58 | default = True 59 | ) 60 | 61 | #fetched on invoke from addonPrefs 62 | zoomAdjust : FloatProperty ( 63 | name="Zoom Adjust", 64 | description="Adjust the zoom amount. (Default: 0)", 65 | soft_min = -2, 66 | soft_max = 2, 67 | default = 0, 68 | ) 69 | 70 | resetZoomAdjust : BoolProperty ( 71 | name="Reset Zoom Adjust", 72 | default = False 73 | ) 74 | 75 | viewSelectMethod : StringProperty ( 76 | name="View Select Method", 77 | description="Whether the view select method is OBJ, SINGLE_VERT, EDGE, FACE, or OBJ", 78 | default="NONE", 79 | ) 80 | 81 | viewSelectionWidth : FloatProperty ( 82 | name="View Selection Width", 83 | description="Width of the selected vert, edge, face, object, or empty", 84 | default=1, 85 | ) 86 | 87 | useZoomAdjust_greenLight = True 88 | 89 | def _draw(self, context): 90 | addonPrefs = context.preferences.addons[__package__].preferences 91 | 92 | scene = context.scene 93 | layout = self.layout.column(align=True) 94 | 95 | if self.frameSelection: 96 | 97 | if not self.useZoomAdjust_greenLight: 98 | layout.label(text="High Vert Count Detected:") 99 | layout.label(text="Zoom Adjust Disabled") 100 | 101 | else: 102 | zoomAdjustRow = layout.row(align=True) 103 | zoomAdjustRow.prop(self, "use_zoomAdjust", text="") 104 | zoomAdjustSlider = zoomAdjustRow.row(align=True) 105 | 106 | bZoomAdjustUseSlider = True 107 | if not self.use_zoomAdjust: 108 | zoomAdjustSlider.enabled = False 109 | bZoomAdjustUseSlider = False 110 | 111 | zoomAdjustSlider.prop(self, "zoomAdjust", slider=bZoomAdjustUseSlider) 112 | 113 | zoomAdjustSlider.separator() 114 | 115 | resetRow = zoomAdjustSlider.row(align=True) 116 | if self.zoomAdjust == 0: 117 | resetRow.active = False 118 | 119 | resetRow.prop(self, "resetZoomAdjust", expand=True, text="", icon="LOOP_BACK", emboss=False) 120 | 121 | def _execute(self, context): 122 | addonPrefs = context.preferences.addons[__package__].preferences 123 | 124 | self.selModeAtBegin = miscFunc.getSelMode() 125 | 126 | self.useZoomAdjust_greenLight = True #reset 127 | 128 | if not self.wasInvoked: 129 | self.invokeView = "EXEC_DEFAULT" 130 | 131 | 132 | scene = context.scene 133 | 134 | if self.resetZoomAdjust: 135 | self.resetZoomAdjust = False 136 | 137 | self.zoomAdjust = 0 138 | 139 | modeAtBegin = "Unknown" 140 | try: 141 | #try to determine objectMode 142 | modeAtBegin = bpy.context.object.mode 143 | except: 144 | modeAtBegin = "OBJECT" 145 | 146 | showErrorMessages = True #declare 147 | if scene.ntzSmFrm.useAdvancedSettings: 148 | if scene.ntzSmFrm.hideErrorMessages: 149 | showErrorMessages = False 150 | 151 | #use all regions when framing? (Useful for quad view) 152 | bUseAllRegions = addonPrefs.useAllRegionsWhenFraming 153 | bUseAll3DAreas = addonPrefs.useAll3DAreasWhenFraming 154 | 155 | objectMode = "Unknown" 156 | selObjs = bpy.context.selected_objects 157 | activeObj = bpy.context.view_layer.objects.active 158 | 159 | 160 | try: 161 | #try to determine objectMode 162 | objectMode = bpy.context.object.mode 163 | except: 164 | objectMode = "OBJECT" 165 | 166 | if activeObj is not None: 167 | if not activeObj in selObjs: 168 | if objectMode == "EDIT": 169 | activeObj.select_set(True) 170 | selObjs.append(activeObj) 171 | 172 | if self.frameMethod == "ORIGIN": 173 | miscFunc.view2Origin(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas) 174 | 175 | elif self.frameMethod == "SEL": 176 | 177 | visibilityCommandList = [ 178 | "context.space_data.show_object_viewport_mesh", 179 | "context.space_data.show_object_viewport_curve", 180 | "context.space_data.show_object_viewport_surf", 181 | "context.space_data.show_object_viewport_meta", 182 | "context.space_data.show_object_viewport_font", 183 | "context.space_data.show_object_viewport_grease_pencil", 184 | "context.space_data.show_object_viewport_armature", 185 | "context.space_data.show_object_viewport_lattice", 186 | "context.space_data.show_object_viewport_empty", 187 | "context.space_data.show_object_viewport_light", 188 | "context.space_data.show_object_viewport_light_probe", 189 | "context.space_data.show_object_viewport_camera", 190 | "context.space_data.show_object_viewport_speaker", 191 | ] 192 | 193 | visibilitySceneBoolList = [ 194 | "addonPrefs.frameMesh", 195 | "addonPrefs.frameCurve", 196 | "addonPrefs.frameSurface", 197 | "addonPrefs.frameMeta", 198 | "addonPrefs.frameText", 199 | "addonPrefs.frameGreasePen", 200 | "addonPrefs.frameArmature", 201 | "addonPrefs.frameLattice", 202 | "addonPrefs.frameEmpty", 203 | "addonPrefs.frameLight", 204 | "addonPrefs.frameLightProbe", 205 | "addonPrefs.frameCamera", 206 | "addonPrefs.frameSpeaker", 207 | ] 208 | 209 | previousVisibility = list() 210 | 211 | 212 | 213 | #if nothing is selected... 214 | if len(selObjs) == 0: 215 | 216 | if self.frameSelection: 217 | #set obj type visibility so that certain object types can be excluded when framing 218 | miscFunc.setObjTypeVisibility(self, context, scene, addonPrefs, visibilityCommandList, previousVisibility, visibilitySceneBoolList) 219 | 220 | #if nothing is selected, object mode,, and there is no active object 221 | if objectMode == "OBJECT" and activeObj == None: 222 | 223 | allSceneObjs = [obj for obj in scene.objects] 224 | 225 | visibleObjsFound = False #declare 226 | 227 | for obj in allSceneObjs: 228 | if obj.visible_get(): 229 | visibleObjsFound = True 230 | break 231 | 232 | if visibleObjsFound > 0: 233 | 234 | if self.frameSelection: 235 | miscFunc.viewAll(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas) 236 | 237 | else: 238 | 239 | if self.frameSelection: 240 | #No objects found! 241 | miscFunc.view2Origin(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas) 242 | 243 | 244 | #if user wants to isolate selection... 245 | if self.isolateSelection: 246 | if scene.ntzSmFrm.currentlyBusyIsolating: 247 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 248 | 249 | else: 250 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 251 | 252 | #nothing is selected, there might be an active object, and the mode might be object/edit 253 | else: 254 | 255 | #if user wants to isolate selection... 256 | if self.isolateSelection: 257 | if scene.ntzSmFrm.currentlyBusyIsolating: 258 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 259 | 260 | else: 261 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 262 | 263 | #user did not want to isolate selection, instead, frame select. 264 | else: 265 | if self.frameSelection: 266 | miscFunc.viewAll(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas) 267 | 268 | #if there's something selected... 269 | elif len(selObjs) > 0: 270 | 271 | 272 | if addonPrefs.expandSelectedObjsInOutliner: 273 | if self.frameSelection: 274 | 275 | # Find and Expand selected objects in each outliner 276 | # ----------------------------------------------------------------------------- 277 | 278 | #store a list of outliners 279 | outliners = miscFunc.getOutliners(self, context) 280 | 281 | if addonPrefs.collapseUnselectedObjsInOutliner: 282 | 283 | miscFunc.expand_or_collapse_outliners(self, context, expand=False, outliners=outliners) 284 | 285 | 286 | miscFunc.expand_selected_objs_in_outliner(self, context, selObjs=selObjs, outliners=outliners, activeObj=activeObj) 287 | 288 | 289 | 290 | if activeObj == None: 291 | bpy.context.view_layer.objects.active = selObjs[0] 292 | activeObj = selObjs[0] 293 | 294 | if objectMode == "EDIT": 295 | 296 | if activeObj.type == "MESH": 297 | 298 | 299 | if self.wasInvoked: 300 | 301 | self.totalVertCount = sum(len(o.evaluated_get(context.evaluated_depsgraph_get()).to_mesh().vertices) for o in context.objects_in_mode) 302 | self.totalNumVertsSel = sum(o.data.total_vert_sel for o in context.objects_in_mode) 303 | 304 | if self.totalVertCount > addonPrefs.maxVertAllowanceForZoomAdjust: 305 | 306 | if self.frameSelection: 307 | 308 | if self.totalNumVertsSel == 0: 309 | forceFrameAllVerts = True 310 | else: 311 | forceFrameAllVerts = False 312 | 313 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj, forceFrameAllVerts=forceFrameAllVerts) 314 | 315 | #isolate missing: 316 | if self.isolateSelection: 317 | 318 | if scene.ntzSmFrm.currentlyBusyIsolating: 319 | miscFunc.unhidePreviouslyHidden_VertsEdgesFaces(self, context, scene) 320 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 321 | 322 | else: 323 | if self.totalNumVertsSel > 0: 324 | miscFunc.hideSelected_VertsEdgesFaces(self, context, scene) 325 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 326 | 327 | else: 328 | 329 | if self.totalNumVertsSel > 0: 330 | 331 | if self.frameSelection: 332 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj, totalNumVertsSel=self.totalNumVertsSel) 333 | 334 | else: 335 | 336 | #no verts selected 337 | if self.frameSelection: 338 | 339 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj, forceFrameAllVerts=True) 340 | 341 | 342 | if self.isolateSelection: 343 | if scene.ntzSmFrm.currentlyBusyIsolating: 344 | miscFunc.unhidePreviouslyHidden_VertsEdgesFaces(self, context, scene) 345 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 346 | 347 | else: 348 | if self.totalNumVertsSel > 0: 349 | miscFunc.hideSelected_VertsEdgesFaces(self, context, scene) 350 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 351 | 352 | elif activeObj.type == "CURVE": 353 | 354 | totalNumCurvePointsSel = 0 #declare 355 | totalNumCurveHandlesLeft = 0 #declare 356 | totalNumCurveHandlesRight = 0 #declare 357 | totalNumCurvePointsAndHandles = 0 #declare 358 | 359 | #get num of selected curve points & handles 360 | for obj in selObjs: 361 | selectedCurvePointsAndHandles = miscFunc.getSelectedCurvePointsAndHandles(self, context, obj) 362 | 363 | if selectedCurvePointsAndHandles is not None: 364 | totalNumCurvePointsSel += len( selectedCurvePointsAndHandles[0] ) 365 | totalNumCurveHandlesLeft += len( selectedCurvePointsAndHandles[1] ) 366 | totalNumCurveHandlesRight += len( selectedCurvePointsAndHandles[2] ) 367 | totalNumCurvePointsAndHandles = totalNumCurvePointsSel + totalNumCurveHandlesLeft + totalNumCurveHandlesRight 368 | 369 | if totalNumCurvePointsAndHandles > 0: 370 | 371 | if self.frameSelection: 372 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 373 | 374 | if self.isolateSelection: 375 | if scene.ntzSmFrm.currentlyBusyIsolating: 376 | miscFunc.unhidePreviouslyHidden_CurvePointsAndHandles(self, context, scene) 377 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 378 | 379 | else: 380 | miscFunc.hideSelected_CurvePointsAndHandles(self, context, scene) 381 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 382 | 383 | else: 384 | 385 | #no curve points and handles selected 386 | if self.frameSelection: 387 | 388 | bpy.ops.object.mode_set(mode = 'OBJECT') 389 | 390 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 391 | 392 | bpy.ops.object.mode_set(mode = 'EDIT') 393 | 394 | elif activeObj.type == "SURFACE": 395 | if self.frameSelection: 396 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 397 | 398 | if self.isolateSelection: 399 | if scene.ntzSmFrm.currentlyBusyIsolating: 400 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 401 | 402 | else: 403 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 404 | 405 | elif activeObj.type == "META": 406 | if self.frameSelection: 407 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 408 | 409 | if self.isolateSelection: 410 | if scene.ntzSmFrm.currentlyBusyIsolating: 411 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 412 | 413 | else: 414 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 415 | 416 | elif activeObj.type == "FONT": 417 | if self.frameSelection: 418 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 419 | 420 | if self.isolateSelection: 421 | if scene.ntzSmFrm.currentlyBusyIsolating: 422 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 423 | 424 | else: 425 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 426 | 427 | elif activeObj.type == "ARMATURE": 428 | if self.frameSelection: 429 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 430 | 431 | if self.isolateSelection: 432 | if scene.ntzSmFrm.currentlyBusyIsolating: 433 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 434 | 435 | else: 436 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 437 | 438 | elif activeObj.type == "LATTICE": 439 | if self.frameSelection: 440 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 441 | 442 | if self.isolateSelection: 443 | if scene.ntzSmFrm.currentlyBusyIsolating: 444 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 445 | 446 | else: 447 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 448 | 449 | else: 450 | if self.frameSelection: 451 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 452 | 453 | if self.isolateSelection: 454 | if scene.ntzSmFrm.currentlyBusyIsolating: 455 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 456 | 457 | else: 458 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 459 | 460 | elif objectMode == "OBJECT": 461 | 462 | 463 | #frame selection 464 | if self.frameSelection: 465 | if self.isolateSelection: 466 | if not scene.ntzSmFrm.currentlyBusyIsolating: 467 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 468 | 469 | else: 470 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 471 | 472 | #isolate selection 473 | if self.isolateSelection: 474 | 475 | if scene.ntzSmFrm.currentlyBusyIsolating: 476 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 477 | 478 | else: 479 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 480 | 481 | 482 | 483 | 484 | 485 | elif objectMode == "EDIT_GPENCIL": 486 | if activeObj.type == "GPENCIL": 487 | if self.frameSelection: 488 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 489 | 490 | if self.isolateSelection: 491 | if scene.ntzSmFrm.currentlyBusyIsolating: 492 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 493 | 494 | else: 495 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 496 | 497 | elif objectMode == "PAINT_GPENCIL": 498 | if activeObj.type == "GPENCIL": 499 | if self.frameSelection: 500 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 501 | 502 | if self.isolateSelection: 503 | if scene.ntzSmFrm.currentlyBusyIsolating: 504 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 505 | 506 | else: 507 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 508 | 509 | elif objectMode == "SCULPT_GPENCIL": 510 | if activeObj.type == "GPENCIL": 511 | if self.frameSelection: 512 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 513 | 514 | if self.isolateSelection: 515 | if scene.ntzSmFrm.currentlyBusyIsolating: 516 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 517 | 518 | else: 519 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 520 | 521 | elif objectMode == "POSE": 522 | if activeObj.type == "ARMATURE": 523 | if self.frameSelection: 524 | miscFunc.viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj) 525 | 526 | if self.isolateSelection: 527 | if scene.ntzSmFrm.currentlyBusyIsolating: 528 | miscFunc.unhidePreviouslyHidden_Objs(self, context, scene) 529 | 530 | else: 531 | miscFunc.hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj) 532 | 533 | #re-enable visibility for all objects 534 | miscFunc.reenableVisibilityForAllObjs(self, context, scene, previousVisibility, visibilityCommandList) 535 | 536 | # final steps 537 | addonPrefs.use_zoomAdjust = self.use_zoomAdjust #update 538 | addonPrefs.zoomAdjust = self.zoomAdjust #update 539 | 540 | 541 | self.wasInvoked = False #reset 542 | 543 | def _invoke(self, context, event): 544 | addonPrefs = context.preferences.addons[__package__].preferences 545 | 546 | scene = context.scene 547 | self.wasInvoked = True 548 | 549 | if addonPrefs.bUseSmoothFraming: 550 | self.invokeView = "INVOKE_DEFAULT" 551 | else: 552 | self.invokeView = "EXEC_DEFAULT" 553 | 554 | self.use_zoomAdjust = addonPrefs.use_zoomAdjust 555 | self.zoomAdjust = addonPrefs.zoomAdjust 556 | 557 | class VIEW3D_OT_ntzsf_smart_frame(Operator, opProps): 558 | """Tooltip""" 559 | bl_idname = "view3d.ntzsf_smart_frame" 560 | bl_label = "NTZSF : Frame" 561 | bl_description = 'Smart Frame selected objects / faces / edges / vertices' 562 | bl_options = {'REGISTER', 'UNDO'} 563 | 564 | @classmethod 565 | def poll(cls, context): 566 | return True 567 | 568 | @classmethod 569 | def description(cls, context, properties): 570 | return properties.tooltip 571 | 572 | def draw(self, context): 573 | _draw(self, context) 574 | 575 | def execute(self, context): 576 | _execute(self, context) 577 | return {'FINISHED'} 578 | # END execute() 579 | 580 | def invoke(self, context, event): 581 | _invoke(self, context, event) 582 | return self.execute(context) 583 | #END invoke() 584 | 585 | # END Operator() 586 | 587 | class VIEW3D_OT_ntzsf_isolate(Operator, opProps): 588 | """Tooltip""" 589 | bl_idname = "view3d.ntzsf_isolate" 590 | bl_label = "NTZSF : Isolate" 591 | bl_description = 'Isolate selected objects / faces / edges / vertices' 592 | bl_options = {'REGISTER', 'UNDO'} 593 | 594 | @classmethod 595 | def poll(cls, context): 596 | return True 597 | 598 | @classmethod 599 | def description(cls, context, properties): 600 | return properties.tooltip 601 | 602 | def draw(self, context): 603 | _draw(self, context) 604 | 605 | def execute(self, context): 606 | _execute(self, context) 607 | return {'FINISHED'} 608 | # END execute() 609 | 610 | def invoke(self, context, event): 611 | _invoke(self, context, event) 612 | return self.execute(context) 613 | #END invoke() 614 | 615 | # END Operator() 616 | 617 | class VIEW3D_OT_ntzsf_frame_and_isolate(Operator, opProps): 618 | """Tooltip""" 619 | bl_idname = "view3d.ntzsf_frame_and_isolate" 620 | bl_label = "NTZSF : Frame & Isolate" 621 | bl_description = 'Frame & Isolate selected objects / faces / edges / vertices' 622 | bl_options = {'REGISTER', 'UNDO'} 623 | 624 | @classmethod 625 | def poll(cls, context): 626 | return True 627 | 628 | @classmethod 629 | def description(cls, context, properties): 630 | return properties.tooltip 631 | 632 | def draw(self, context): 633 | _draw(self, context) 634 | 635 | def execute(self, context): 636 | _execute(self, context) 637 | return {'FINISHED'} 638 | # END execute() 639 | 640 | def invoke(self, context, event): 641 | _invoke(self, context, event) 642 | return self.execute(context) 643 | #END invoke() 644 | 645 | # END Operator() 646 | 647 | class VIEW3D_OT_ntzsf_viewport_to_origin(Operator, opProps): 648 | """Tooltip""" 649 | bl_idname = "view3d.ntzsf_viewport_to_origin" 650 | bl_label = "NTZSF : Viewport to Origin" 651 | bl_description = 'Move the viewport to the origin' 652 | bl_options = {'REGISTER', 'UNDO'} 653 | 654 | @classmethod 655 | def poll(cls, context): 656 | return True 657 | 658 | @classmethod 659 | def description(cls, context, properties): 660 | return properties.tooltip 661 | 662 | def draw(self, context): 663 | _draw(self, context) 664 | 665 | def execute(self, context): 666 | _execute(self, context) 667 | return {'FINISHED'} 668 | # END execute() 669 | 670 | def invoke(self, context, event): 671 | _invoke(self, context, event) 672 | return self.execute(context) 673 | #END invoke() 674 | 675 | # END Operator() 676 | -------------------------------------------------------------------------------- /miscFunc.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import bmesh 3 | import numpy 4 | 5 | from operator import itemgetter 6 | from mathutils import Vector 7 | from itertools import chain 8 | from itertools import permutations 9 | 10 | def average(lst): 11 | return sum(lst) / len(lst) 12 | 13 | # ----------------------------------------------------------------------------- 14 | # Determine which mode is currently Selected (Vert, Edge, Face, etc) 15 | # Returned: (0=Multiple modes, 1=Vertice Mode, 2=Edge Mode, 3=Face Mode) 16 | # ----------------------------------------------------------------------------- 17 | 18 | def getSelMode(): 19 | #Create empty list 20 | tempList = [] 21 | 22 | #check current mesh select mode 23 | for bool in bpy.context.tool_settings.mesh_select_mode: 24 | tempList.append(bool) 25 | 26 | #convert list into a tuple 27 | currentSelectMode = tuple(tempList) 28 | 29 | return currentSelectMode 30 | # END getSelMode(self, context) 31 | 32 | def setSelMode( selBoolTuple): 33 | bpy.context.tool_settings.mesh_select_mode = selBoolTuple 34 | # END getSelMode(self, context) 35 | 36 | 37 | def getAllCurvePointsAndHandles(self, context, obj): 38 | if obj.type == "CURVE": 39 | curve = obj.data 40 | 41 | #switch to object mode 42 | bpy.ops.object.mode_set(mode='OBJECT') 43 | 44 | curvePointList = [p for p in curve.splines.active.bezier_points] 45 | curveHandlesLeft = [p for p in curve.splines.active.bezier_points] 46 | curveHandlesRight = [p for p in curve.splines.active.bezier_points] 47 | 48 | all_curve_points_and_handles = [curvePointList, curveHandlesLeft, curveHandlesRight] 49 | 50 | #switch back to edit mode 51 | bpy.ops.object.mode_set(mode='EDIT') 52 | 53 | return all_curve_points_and_handles 54 | 55 | def getSelectedCurvePointsAndHandles(self, context, obj): 56 | if obj.type == "CURVE": 57 | curve = obj.data 58 | 59 | #switch to object mode 60 | bpy.ops.object.mode_set(mode='OBJECT') 61 | 62 | curvePointList = [p for p in curve.splines.active.bezier_points if p.select_control_point] 63 | curveHandlesLeftList = [p for p in curve.splines.active.bezier_points if p.select_left_handle] 64 | curveHandlesRightList = [p for p in curve.splines.active.bezier_points if p.select_right_handle] 65 | 66 | selected_curve_points_and_handles = [curvePointList, curveHandlesLeftList, curveHandlesRightList] 67 | 68 | #switch back to edit mode 69 | bpy.ops.object.mode_set(mode='EDIT') 70 | 71 | return selected_curve_points_and_handles 72 | 73 | def hideUnselected_Objs(self, context, scene, addonPrefs, selObjs, activeObj): 74 | 75 | foundObjectToHide = False #initial declare 76 | 77 | #loop through all objects in scene and put a custom prop so we know which objects to unhide 78 | for obj in bpy.context.scene.objects: 79 | 80 | if obj not in selObjs: 81 | if obj.visible_get(): #ensure object is visible, that way later on, user preferred hidden objects don't get revealed accidentally 82 | if 'ntzSmFrm_isolateExcluded' in obj: 83 | pass 84 | else: 85 | obj['ntzSmFrm_hidden'] = 1 86 | 87 | #should object use extreme hidden to grant a big performance increase? 88 | if addonPrefs.useExtremeHideOnIsolate: 89 | if obj.hide_viewport == False: 90 | obj.hide_viewport = True 91 | 92 | foundObjectToHide = True 93 | 94 | if foundObjectToHide: 95 | scene.ntzSmFrm.currentlyBusyIsolating = True 96 | 97 | hideFloorAndAxes(self, context, scene, addonPrefs) 98 | 99 | #hide all but selected 100 | for obj in bpy.context.scene.objects: 101 | if 'ntzSmFrm_hidden' in obj: 102 | obj.hide_set(True) #unhide object 103 | 104 | foundObjectToHide = False #reset 105 | 106 | else: 107 | scene.ntzSmFrm.currentlyBusyIsolating = True 108 | 109 | hideFloorAndAxes(self, context, scene, addonPrefs) 110 | 111 | def hideFloorAndAxes(self, context, scene, addonPrefs): 112 | #store current floor visibility for use later: 113 | scene.ntzSmFrm.floorWasPreviouslyVisible = bpy.context.space_data.overlay.show_floor 114 | 115 | #store current axes visibility for use later: 116 | scene.ntzSmFrm.axis_x_wasPreviouslyVisible = bpy.context.space_data.overlay.show_axis_x 117 | scene.ntzSmFrm.axis_y_wasPreviouslyVisible = bpy.context.space_data.overlay.show_axis_y 118 | scene.ntzSmFrm.axis_z_wasPreviouslyVisible = bpy.context.space_data.overlay.show_axis_z 119 | 120 | if addonPrefs.hideFloorOnIsolate: 121 | bpy.context.space_data.overlay.show_floor = False 122 | 123 | if addonPrefs.hideAxesOnIsolate: 124 | bpy.context.space_data.overlay.show_axis_x = False 125 | bpy.context.space_data.overlay.show_axis_y = False 126 | bpy.context.space_data.overlay.show_axis_z = False 127 | 128 | def unhidePreviouslyHidden_Objs(self, context, scene): 129 | 130 | #restore floor visibility 131 | if scene.ntzSmFrm.floorWasPreviouslyVisible: 132 | bpy.context.space_data.overlay.show_floor = True 133 | 134 | #restore axes visibility 135 | if scene.ntzSmFrm.axis_x_wasPreviouslyVisible: 136 | bpy.context.space_data.overlay.show_axis_x = True 137 | 138 | if scene.ntzSmFrm.axis_y_wasPreviouslyVisible: 139 | bpy.context.space_data.overlay.show_axis_y = True 140 | 141 | if scene.ntzSmFrm.axis_z_wasPreviouslyVisible: 142 | bpy.context.space_data.overlay.show_axis_z = True 143 | 144 | #loop through all objects in scene check the custom prop 145 | for obj in bpy.context.scene.objects: 146 | if 'ntzSmFrm_hidden' in obj: 147 | if obj['ntzSmFrm_hidden'] == 1: 148 | obj.hide_set(False) #unhide object 149 | 150 | 151 | #Ensure "Show in Viewports" is enabled 152 | if obj.hide_viewport == True: 153 | obj.hide_viewport = False 154 | 155 | del obj['ntzSmFrm_hidden'] 156 | 157 | scene.ntzSmFrm.currentlyBusyIsolating = False 158 | 159 | 160 | def hideSelected_VertsEdgesFaces(self, context, scene): 161 | bpy.ops.mesh.hide(unselected=True) 162 | scene.ntzSmFrm.currentlyBusyIsolating = True 163 | 164 | def unhidePreviouslyHidden_VertsEdgesFaces(self, context, scene): 165 | bpy.ops.mesh.reveal(select=False) 166 | scene.ntzSmFrm.currentlyBusyIsolating = False 167 | 168 | def hideSelected_CurvePointsAndHandles(self, context, scene): 169 | bpy.ops.curve.hide(unselected=True) 170 | scene.ntzSmFrm.currentlyBusyIsolating = True 171 | 172 | def unhidePreviouslyHidden_CurvePointsAndHandles(self, context, scene): 173 | bpy.ops.curve.reveal() 174 | scene.ntzSmFrm.currentlyBusyIsolating = False 175 | 176 | def setObjTypeVisibility(self, context, scene, addonPrefs, visibilityCommandList, previousVisibility, visibilitySceneBoolList): 177 | #store previousVisibility so that it can be returned to original setting later 178 | for index, command in enumerate(visibilityCommandList): 179 | #store previousVisibility so that it can be returned to original setting later 180 | previousVisibility += list( [ eval(command) ] ) 181 | 182 | commandToEval = command + " = " + visibilitySceneBoolList[index] 183 | eval(compile(commandToEval,'','exec')) 184 | 185 | def reenableVisibilityForAllObjs(self, context, scene, previousVisibility, visibilityCommandList): 186 | for index, boool in enumerate(previousVisibility): 187 | commandToEval = visibilityCommandList[index] + " = " + str(boool) 188 | eval(compile(commandToEval,'','exec')) 189 | 190 | def getSelObjsFromOutlinerAndViewport(self, context, modeAtBegin): 191 | #NOTE: modeAtBegin is "OBJECT" or "EDIT" mode 192 | 193 | outlinerBlueHighlightedObjs = set() #declare 194 | selObjs = set() #declare 195 | 196 | # Select objects in outliner 197 | area = None #declare 198 | try: 199 | #check for outliner in the main window 200 | area = next(a for a in context.screen.areas if a.type == 'OUTLINER') 201 | except: 202 | try: 203 | #check for outliner in other windows 204 | area = next(a for w in context.window_manager.windows 205 | for a in w.screen.areas if a.type == 'OUTLINER') 206 | except: 207 | pass 208 | 209 | if area is not None: 210 | sel_org = context.selected_objects[:] 211 | objs = context.view_layer.objects 212 | 213 | hide_select = {o for o in objs if o.hide_select} 214 | for o in hide_select: # Toggle off hide select 215 | o.hide_select = False 216 | 217 | for o in sel_org: # Deselect all selected 218 | o.select_set(False) 219 | 220 | bpy.ops.outliner.object_operation({'area': area}, type='SELECT') 221 | 222 | outlinerBlueHighlightedObjs = context.selected_objects[:] 223 | 224 | # Toggle on hide select for objects not selected in outliner 225 | for o in hide_select: 226 | if not o.select_get(): 227 | o.hide_select = True 228 | 229 | for o in sel_org: # Restore original selection 230 | o.select_set(True) 231 | 232 | selObjs = set(bpy.context.selected_objects) 233 | activeObj = bpy.context.view_layer.objects.active 234 | 235 | if activeObj is not None: 236 | if not activeObj in selObjs: 237 | if modeAtBegin == "EDIT": 238 | selObjs.add(activeObj) 239 | 240 | selObjs.union(outlinerBlueHighlightedObjs) 241 | 242 | #if unable to retreive obects from outliner, then retrieve objects normally from sel objs and active object 243 | else: 244 | selObjs = bpy.context.selected_objects 245 | activeObj = bpy.context.view_layer.objects.active 246 | 247 | if activeObj is not None: 248 | if not activeObj in selObjs: 249 | if modeAtBegin == "EDIT": 250 | selObjs.add(activeObj) 251 | 252 | return selObjs 253 | 254 | 255 | def viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjs, activeObj, totalNumVertsSel=0, forceFrameAllVerts=False): 256 | 257 | winAreaRegionInfoList = [] #declare 258 | 259 | self.useZoomAdjust_greenLight = (self.totalVertCount <= addonPrefs.maxVertAllowanceForZoomAdjust) and (totalNumVertsSel <= addonPrefs.maxVertSelectionAllowanceForZoomAdjust) 260 | 261 | if forceFrameAllVerts: 262 | 263 | setSelMode( (True, False, False) ) 264 | 265 | for obj in bpy.context.objects_in_mode: 266 | bm = bmesh.from_edit_mesh(obj.data) 267 | 268 | for v in bm.verts: 269 | v.select = True 270 | 271 | bm.select_flush(True) #force faces to also sorta be selected so that framing is correct with multiple mesh objects in edit mode 272 | bmesh.update_edit_mesh(obj.data, False, False) 273 | 274 | if self.use_zoomAdjust and self.useZoomAdjust_greenLight: 275 | 276 | viewClipStartList = [] #declare 277 | self.viewSelectMethod = "NONE" #declare 278 | allSelVerts = [] #declare 279 | minEdgeLength = 0 #declare 280 | 281 | objWithSingleVert = None 282 | 283 | 284 | 285 | if self.wasInvoked: 286 | #determine which view select method to use 287 | if activeObj is not None: 288 | self.viewSelectMethod = "OBJ" 289 | 290 | if activeObj.type == "MESH": 291 | if modeAtBegin == "EDIT": 292 | 293 | allSelVertIDs = [] #declare 294 | for obj in bpy.context.objects_in_mode: 295 | bm = bmesh.from_edit_mesh(obj.data) 296 | 297 | for v in bm.verts: 298 | if v.select: 299 | selVertIDs = [{"OBJNAME": obj.name, "VERTID": v.index}] 300 | allSelVertIDs = allSelVertIDs + selVertIDs 301 | 302 | if len(allSelVertIDs) == 1: 303 | self.viewSelectMethod = "SINGLE_VERT" 304 | _dict = selVertIDs[0] 305 | objWithSingleVert = bpy.data.objects[ _dict['OBJNAME'] ] 306 | 307 | elif len(allSelVertIDs) == 2: 308 | self.viewSelectMethod = "EDGE" 309 | 310 | elif len(allSelVertIDs) > 2: 311 | self.viewSelectMethod = "FACE" 312 | 313 | #determine the bounding box size 314 | if self.viewSelectMethod == "SINGLE_VERT": 315 | self.viewSelectionWidth = max_dim_from_single_vert_and_adjacent_verts(self, context, scene, addonPrefs, objWithSingleVert) 316 | 317 | elif self.viewSelectMethod == "EDGE": 318 | self.viewSelectionWidth = ( max_dim_from_selection(self, context, scene, addonPrefs) * 1) 319 | 320 | elif self.viewSelectMethod == "FACE": 321 | self.viewSelectionWidth = ( max_dim_from_selection(self, context, scene, addonPrefs) * 1) 322 | 323 | elif self.viewSelectMethod == "OBJ": 324 | self.viewSelectionWidth = ( max_dim_from_objs_or_empties(self, context, scene, addonPrefs, selObjs) * 1) 325 | 326 | 327 | 328 | 329 | if bUseAll3DAreas: 330 | 331 | # Check for 3D Views 332 | for win in context.window_manager.windows: 333 | for area in win.screen.areas: 334 | if area.type == 'VIEW_3D': 335 | 336 | if self.use_zoomAdjust and self.useZoomAdjust_greenLight: 337 | 338 | viewClipStart = area.spaces.active.clip_start 339 | viewClipStartList.append(viewClipStart) 340 | 341 | #view selected 342 | winAreaRegionInfo = {'window': win, 'area': area, 'region': area.regions[-1]} 343 | winAreaRegionInfoList.append(winAreaRegionInfo) 344 | 345 | else: 346 | viewClipStartList = [bpy.context.area.spaces.active.clip_start] 347 | winAreaRegionInfoList = [context.copy()] 348 | 349 | 350 | for i, winAreaRegionInfo in enumerate(winAreaRegionInfoList): 351 | 352 | if self.use_zoomAdjust and self.useZoomAdjust_greenLight: 353 | 354 | if bUseAll3DAreas: 355 | area = winAreaRegionInfoList[i]['area'] 356 | else: 357 | area = bpy.context.area 358 | 359 | #determine clip start value for zooming 360 | clip_start_result = self.viewSelectionWidth + (self.viewSelectionWidth * self.zoomAdjust) 361 | area.spaces.active.clip_start = clip_start_result 362 | 363 | bpy.ops.view3d.view_selected(winAreaRegionInfo, self.invokeView, use_all_regions=bUseAllRegions) 364 | 365 | if self.use_zoomAdjust and self.useZoomAdjust_greenLight: 366 | #return clip start values back to their original value after framing 367 | area.spaces.active.clip_start = viewClipStartList[i] 368 | 369 | 370 | if forceFrameAllVerts: 371 | for obj in selObjs: 372 | bm = bmesh.from_edit_mesh(obj.data) 373 | for v in bm.verts: 374 | v.select = False 375 | 376 | bm.select_flush(False) #force faces to be deselected 377 | bmesh.update_edit_mesh(obj.data, False, False) 378 | 379 | setSelMode(self.selModeAtBegin) 380 | 381 | 382 | 383 | 384 | 385 | 386 | def viewAll(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas): 387 | # Note: Only use this function in object mode - Never edit mode. 388 | 389 | selObjsTemp = [] #declare 390 | 391 | #select all objects except ones excluded from framing 392 | for obj in scene.objects: 393 | 394 | try: 395 | frameObjType = addonPrefs.frameObjTypeList2[obj.type] 396 | except: 397 | frameObjType = None 398 | 399 | #known object types: 400 | if frameObjType is not None: 401 | 402 | frameTypeState = getattr(addonPrefs, frameObjType) 403 | 404 | if frameTypeState: 405 | obj.select_set(True) 406 | selObjsTemp.append(obj) 407 | 408 | #unknown object type 409 | else: 410 | obj.select_set(True) 411 | selObjsTemp.append(obj) 412 | 413 | #declare an active object for the viewSelected function 414 | if len(selObjsTemp) > 0: 415 | activeObjTemp = selObjsTemp[0] 416 | viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, selObjsTemp, activeObjTemp) 417 | else: 418 | view2Origin(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas) 419 | 420 | 421 | 422 | #deselect all objects 423 | for obj in scene.objects: 424 | obj.select_set(False) 425 | 426 | 427 | 428 | def view2Origin(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas): 429 | 430 | #create obj 431 | bpy.ops.object.empty_add(type='PLAIN_AXES', radius=5, location=(0, 0, 0)) 432 | 433 | #if empty object type view was disabled, it must be re-enabled temporarily in order to determine the selected object 434 | emptyViewWasDisabled = False #declare 435 | if not context.space_data.show_object_viewport_empty: 436 | emptyViewWasDisabled = True 437 | context.space_data.show_object_viewport_empty = True 438 | 439 | tempEmptyObj = context.selected_objects[0] 440 | 441 | winAreaRegionInfoList = [] 442 | 443 | # Check for 3D Views 444 | 445 | if bUseAll3DAreas: 446 | for win in context.window_manager.windows: 447 | for area in win.screen.areas: 448 | if area.type == 'VIEW_3D': 449 | 450 | winAreaRegionInfo = {'window': win, 'area': area, 'region': area.regions[-1]} 451 | winAreaRegionInfoList.append(winAreaRegionInfo) 452 | 453 | else: 454 | winAreaRegionInfoList = [context.copy()] 455 | 456 | for winAreaRegionInfo in winAreaRegionInfoList: 457 | 458 | #view to origin 459 | viewSelected(self, context, scene, addonPrefs, modeAtBegin, bUseAllRegions, bUseAll3DAreas, [tempEmptyObj], tempEmptyObj) 460 | 461 | bpy.ops.object.delete(use_global=False, confirm=False) 462 | 463 | if emptyViewWasDisabled: 464 | context.space_data.show_object_viewport_empty = False 465 | 466 | def bbox_from_selection(): 467 | #returns the bounding box of a selection. Special thanks and Source: iceythe 468 | all_vcos = [] 469 | # Get all vert cos from objects in edit mode 470 | for o in bpy.context.objects_in_mode_unique_data: 471 | bm = bmesh.from_edit_mesh(o.data) 472 | mat = o.matrix_world 473 | all_vcos.extend([mat @ v.co for v in bm.verts if v.select]) 474 | 475 | (x1, y1, z1, 476 | x2, y2, z2) = [func(all_vcos, key=itemgetter(i))[i] 477 | for func in (min, max) for i in range(3)] 478 | 479 | bbox = ( 480 | (x1, y1, z1), (x1, y1, z2), 481 | (x2, y1, z2), (x2, y1, z1), 482 | 483 | # mirror other size 484 | (x1, y2, z1), (x1, y2, z2), 485 | (x2, y2, z2), (x2, y2, z1)) 486 | 487 | bbox_vecs = [Vector(i) for i in bbox] 488 | 489 | 490 | return bbox_vecs 491 | 492 | 493 | def max_dim_from_single_vert_and_adjacent_verts(self, context, scene, addonPrefs, objWithSingleVert): 494 | 495 | bm = bmesh.from_edit_mesh(objWithSingleVert.data) 496 | mat = objWithSingleVert.matrix_world 497 | 498 | #find linked vertices - Source: https://blenderartists.org/t/code-snippet-with-bmesh-find-the-linked-vertices/534077 499 | selectedVert = [] #declare 500 | linkedVerts = [] #declare 501 | for i_0, v_0 in enumerate(bm.verts): 502 | if v_0.select: 503 | selectedVert.append( mat @ v_0.co ) 504 | if v_0.select and v_0.is_valid: 505 | for i_1, e_0 in enumerate(v_0.link_edges): 506 | linkedVerts.append(mat @ e_0.other_vert(v_0).co) 507 | 508 | all_vcos = [] #declare 509 | all_vcos.extend(selectedVert) 510 | all_vcos.extend(linkedVerts) 511 | 512 | it = numpy.fromiter(chain.from_iterable(all_vcos), dtype=float) 513 | it.shape = (len(all_vcos), 3) 514 | _min, _max = Vector(it.min(0).tolist()), Vector(it.max(0).tolist()) 515 | 516 | if addonPrefs.calcZoomDistanceMethod == "MIN": 517 | result = min((_max - _min)) 518 | elif addonPrefs.calcZoomDistanceMethod == "MAX": 519 | result = max((_max - _min)) 520 | elif addonPrefs.calcZoomDistanceMethod == "AVG": 521 | result = average((_max - _min)) 522 | 523 | if result == 0: 524 | result = 1 525 | 526 | return result 527 | 528 | def max_dim_from_selection(self, context, scene, addonPrefs): 529 | 530 | scene = context.scene 531 | 532 | #Get max dimension from selection - Special thanks & source: iceythe 533 | 534 | all_vcos = [] 535 | # Get all vert cos from objects in edit mode 536 | for o in bpy.context.objects_in_mode_unique_data: 537 | bm = bmesh.from_edit_mesh(o.data) 538 | mat = o.matrix_world 539 | all_vcos.extend([(mat @ v.co)[:] for v in bm.verts if v.select]) 540 | 541 | it = numpy.fromiter(chain.from_iterable(all_vcos), dtype=float) 542 | it.shape = (len(all_vcos), 3) 543 | _min, _max = Vector(it.min(0).tolist()), Vector(it.max(0).tolist()) 544 | 545 | if addonPrefs.calcZoomDistanceMethod == "MIN": 546 | result = min((_max - _min)) 547 | elif addonPrefs.calcZoomDistanceMethod == "MAX": 548 | result = max((_max - _min)) 549 | elif addonPrefs.calcZoomDistanceMethod == "AVG": 550 | result = average((_max - _min)) 551 | 552 | return result 553 | 554 | def max_dim_from_objs_or_empties(self, context, scene, addonPrefs, selObjs): 555 | scene = context.scene 556 | 557 | #Get max dimension from objects and empties - Special thanks & source: iceythe 558 | all_vcos = [] 559 | for o in selObjs: 560 | mat_w = o.matrix_world 561 | if o.type == 'EMPTY': 562 | size = o.empty_display_size 563 | all_vcos.extend([mat_w @ Vector(point) for point in 564 | permutations((-size, size) * 2, 3)]) 565 | continue 566 | all_vcos.extend([mat_w @ Vector(point[:]) 567 | for point in o.bound_box[:]]) 568 | 569 | it = numpy.fromiter(chain.from_iterable((all_vcos)), dtype=float) 570 | it.shape = (len(all_vcos), 3) 571 | _min, _max = Vector(it.min(0).tolist()), Vector(it.max(0).tolist()) 572 | 573 | if addonPrefs.calcZoomDistanceMethod == "MIN": 574 | result = min((_max - _min)) 575 | elif addonPrefs.calcZoomDistanceMethod == "MAX": 576 | result = max((_max - _min)) 577 | elif addonPrefs.calcZoomDistanceMethod == "AVG": 578 | result = average((_max - _min)) 579 | 580 | #prevent zero result 581 | if result == 0: 582 | result = 1 583 | 584 | return result 585 | 586 | 587 | def getOutliners(self, context): 588 | outliners = [] #declare 589 | for win in context.window_manager.windows: 590 | for area in win.screen.areas: 591 | if area.type == 'OUTLINER': 592 | outliners.append({'window' : win, 'area': area}) 593 | 594 | return outliners 595 | 596 | def expand_or_collapse_outliners(self, context, expand=False, outliners=None): 597 | 598 | if outliners is None: 599 | outliners = getOutliners(self, context) 600 | 601 | for outliner in outliners: 602 | win = outliner['window'] 603 | area = outliner['area'] 604 | contextOverride = {'window': win, 'screen': win.screen, 'area': area} 605 | 606 | if expand: 607 | bpy.ops.outliner.show_hierarchy(contextOverride) 608 | 609 | else: 610 | # horribly sloppy implementation 611 | for i in range(0,10): 612 | bpy.ops.outliner.show_one_level(contextOverride, open=False) 613 | 614 | def expand_selected_objs_in_outliner(self, context, selObjs=None, outliners=None, activeObj=None): 615 | 616 | if activeObj is None: 617 | activeObj = context.view_layer.objects.active 618 | 619 | if selObjs is None: 620 | selObjs = bpy.context.selected_objects 621 | 622 | if outliners is None: 623 | outliners = getOutliners(self, context) 624 | 625 | for obj in selObjs: 626 | context.view_layer.objects.active = obj #set object as active object 627 | 628 | for outliner in outliners: 629 | win = outliner['window'] 630 | area = outliner['area'] 631 | 632 | contextOverride = {'window': win, 'screen': win.screen, 'area': area} 633 | 634 | bpy.ops.outliner.show_active(contextOverride) 635 | 636 | if activeObj is not None: 637 | context.view_layer.objects.active = activeObj #reset Active Object 638 | 639 | # END expand_selected_objs_in_outliner() 640 | 641 | 642 | def redraw_all_outliners(self, context, outliners=None): 643 | 644 | if outliners is None: 645 | outliners = getOutliners(self, context) 646 | 647 | for outliner in outliners: 648 | outliner['area'].tag_redraw() #redraw outliner 649 | -------------------------------------------------------------------------------- /miscLay.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | #Show hide section with arrow, optional checkbox, and text 4 | def createShowHide(self, context, scene, properties, showHideBool, optionalCheckboxBool, text, layout): 5 | 6 | if scene is not None: 7 | data = eval( f"scene.{properties}" ) 8 | boolThing = eval( f"scene.{properties}.{showHideBool}" ) 9 | else: 10 | data = self 11 | boolThing = eval( f"self.{showHideBool}") 12 | 13 | if boolThing: 14 | showHideIcon = "TRIA_DOWN" 15 | else: 16 | showHideIcon = "TRIA_RIGHT" 17 | 18 | row = layout.row(align=True) 19 | 20 | downArrow = row.column(align=True) 21 | downArrow.alignment = "LEFT" 22 | downArrow.prop(data, showHideBool, text="", icon=showHideIcon, emboss=False ) 23 | 24 | if optionalCheckboxBool is not None: 25 | checkbox = row.column(align=True) 26 | checkbox.alignment = "LEFT" 27 | checkbox.prop(data, optionalCheckboxBool, text="" ) 28 | 29 | textRow = row.column(align=True) 30 | textRow.alignment = "LEFT" 31 | textRow.prop(data, showHideBool, text=text, emboss=False ) 32 | 33 | emptySpace = row.column(align=True) 34 | emptySpace.alignment = "EXPAND" 35 | emptySpace.prop(data, showHideBool, text=" ", emboss=False) 36 | 37 | def createProp(self, context, scene, bEnabled, labelText, data, propItem, scale_y, labelWidth, propWidth, labelJustify, propJustify, propText, bExpandProp, bUseSlider, layout): 38 | 39 | propRow = layout.row(align=True) 40 | 41 | if not bEnabled: 42 | propRow.enabled = False 43 | 44 | propRow.scale_y = scale_y 45 | 46 | propRowLabel = propRow.row(align=True) 47 | propRowLabel.alignment="EXPAND" 48 | propRowLabel.ui_units_x = labelWidth 49 | 50 | propRowLabel1 = propRowLabel.row(align=True) 51 | propRowLabel1.alignment=labelJustify 52 | propRowLabel1.scale_x = 1 53 | 54 | propRowLabel1.label(text=labelText) 55 | 56 | propRowItem = propRow.row(align=True) 57 | propRowItem.alignment=propJustify 58 | 59 | propRowItem1 = propRowItem.row(align=True) 60 | propRowItem1.alignment=propJustify 61 | propRowItem1.ui_units_x = propWidth 62 | propRowItem1.scale_x = 100 63 | 64 | propRowItem1.prop(data, propItem, text=propText, expand=bExpandProp, slider=bUseSlider) 65 | 66 | def sep(scaleY, layout): 67 | #custom separator that allows shorter y distance 68 | sep = layout.column(align=True) 69 | sep.label(text="",) 70 | sep.scale_y = scaleY 71 | 72 | def mainSmartFramePanel(self, context, bUseCompactSidebarPanel, bUseCompactPopupAndPiePanel): 73 | 74 | scene = context.scene 75 | layout = self.layout.column(align=True) 76 | addonPrefs = context.preferences.addons[__package__].preferences 77 | 78 | #determine if panel is inside of a popop/pie menu 79 | panelInsidePopupOrPie = context.region.type == 'WINDOW' 80 | 81 | if panelInsidePopupOrPie: 82 | 83 | if bUseCompactPopupAndPiePanel: 84 | layout.ui_units_x = 8 85 | layout.label(text="Smart Frame") 86 | 87 | else: 88 | layout.ui_units_x = 13 89 | layout.label(text="Neltulz - Smart Frame") 90 | 91 | #main frame & isolate buttons 92 | frameIsolateButtons_section(self, context, scene, addonPrefs, panelInsidePopupOrPie, bUseCompactSidebarPanel, bUseCompactPopupAndPiePanel, layout) 93 | 94 | 95 | def frameIsolateButtons_section(self, context, scene, addonPrefs, panelInsidePopupOrPie, bUseCompactSidebarPanel, bUseCompactPopupAndPiePanel, layout): 96 | 97 | compactPanelConditions = (panelInsidePopupOrPie and bUseCompactPopupAndPiePanel) or (not panelInsidePopupOrPie and bUseCompactSidebarPanel) 98 | 99 | if compactPanelConditions: 100 | frameText = "Frm" 101 | if addonPrefs.useExtremeHideOnIsolate: 102 | isolateText = "E-Iso" 103 | isolateIcon="NONE" 104 | else: 105 | isolateText = "Iso" 106 | isolateIcon="NONE" 107 | scaleY = 1 108 | frameAndIsolateText = "Frm+Iso" 109 | templateText = "Tmplt" 110 | viewOriginText = "View2Ori" 111 | else: 112 | frameText = "Frame" 113 | if addonPrefs.useExtremeHideOnIsolate: 114 | isolateText = "Ext Isolate" 115 | isolateIcon="ERROR" 116 | else: 117 | isolateIcon="NONE" 118 | isolateText = "Isolate" 119 | scaleY = 1.5 120 | frameAndIsolateText = "Frame & Isolate" 121 | templateText = "Template" 122 | viewOriginText = "Viewport to Origin" 123 | 124 | frameAndIsolateRow = layout.row(align=True) 125 | frameAndIsolateRow.scale_y = scaleY 126 | 127 | 128 | 129 | frameRow = frameAndIsolateRow.row(align=True) 130 | 131 | frameOpRow = frameRow.column(align=True) 132 | frameOpRow.alignment="EXPAND" 133 | frameOpRow.scale_x = 100 134 | op = frameOpRow.operator('view3d.ntzsf_smart_frame', text=frameText, icon="NONE") 135 | op.tooltip = "Frame an object, selection of objects, vertice, edge, face, or when all else fails: frame everything" 136 | op.frameSelection = True 137 | op.isolateSelection = False 138 | op.frameMethod = "SEL" 139 | 140 | framePopoverRow = frameRow.row(align=True) 141 | popover = framePopoverRow.popover(text="", panel="VIEW3D_PT_ntzsf_frame_options", icon="DOWNARROW_HLT") 142 | 143 | frameAndIsolateRow.separator() 144 | 145 | isolateRow = frameAndIsolateRow.row(align=True) 146 | 147 | if scene.ntzSmFrm.currentlyBusyIsolating: 148 | isolateText = "Unhide" 149 | 150 | isolateOpRow = isolateRow.row(align=True) 151 | isolateOpRow.alignment="EXPAND" 152 | isolateOpRow.scale_x = 100 153 | op = isolateOpRow.operator('view3d.ntzsf_isolate', text=isolateText, icon=isolateIcon) 154 | op.tooltip = "Isolate an object, selection of objects, vertice, edge, face, or when all else fails: isolate everything" 155 | op.frameSelection = False 156 | op.isolateSelection = True 157 | op.frameMethod = "SEL" 158 | 159 | IsolatePopoverRow = isolateRow.row(align=True) 160 | popover = IsolatePopoverRow.popover(text="", panel="VIEW3D_PT_ntzsf_isolate_options", icon="DOWNARROW_HLT") 161 | 162 | layout.separator() 163 | 164 | #Frame & Isolate AND Template Row 165 | frameAndIsolateAndTemplateRow = layout.row(align=True) 166 | frameAndIsolateAndTemplateRow.scale_y = scaleY 167 | 168 | frameAndIsolateRow = frameAndIsolateAndTemplateRow.row(align=True) 169 | 170 | frameAndIsolateOpRow = frameAndIsolateRow.row(align=True) 171 | frameAndIsolateOpRow.alignment="EXPAND" 172 | frameAndIsolateOpRow.scale_x = 100 173 | 174 | if scene.ntzSmFrm.currentlyBusyIsolating: 175 | frameAndIsolateOpRow.enabled=False 176 | op = frameAndIsolateOpRow.operator('view3d.ntzsf_frame_and_isolate', text=frameAndIsolateText) 177 | op.tooltip = "Frame and Isolate an object, selection of objects, vertices, edges, or faces, simultaneously, or when all else fails: everything" 178 | op.frameSelection = True 179 | op.isolateSelection = True 180 | op.frameMethod = "SEL" 181 | 182 | frameAndIsolateAndTemplateRow.separator() 183 | 184 | templateRow = frameAndIsolateAndTemplateRow.row(align=True) 185 | 186 | templateOpRow = templateRow.row(align=True) 187 | templateOpRow.alignment="EXPAND" 188 | templateOpRow.scale_x = 100 189 | 190 | op = templateOpRow.operator('view3d.ntzsf_toggle_template', text=templateText, icon="NONE") 191 | op.tooltip = "Converts an object to a wireframe with click-through (unselectable) capability for reference purposes" 192 | 193 | templatePopoverRow = templateRow.row(align=True) 194 | popover = templatePopoverRow.popover(text="", panel="VIEW3D_PT_ntzsf_tmpl_options", icon="DOWNARROW_HLT") 195 | 196 | layout.separator() 197 | 198 | 199 | #Viewport to Origin 200 | col = layout.column(align=True) 201 | op = col.operator('view3d.ntzsf_viewport_to_origin', text=viewOriginText) 202 | op.tooltip = "Move the viewport to the origin" 203 | op.frameSelection = True 204 | op.isolateSelection = False 205 | op.frameMethod = "ORIGIN" 206 | 207 | def frameOptions_sectionInner(self, context, scene, addonPrefs, layout): 208 | 209 | layout.prop(addonPrefs, "bUseSmoothFraming", expand=True) 210 | 211 | layout.separator() 212 | 213 | layout.prop(addonPrefs, "expandSelectedObjsInOutliner", expand=True) 214 | 215 | 216 | layout.separator() 217 | 218 | layout.label(text="Experimental:") 219 | row = layout.row(align=True) 220 | row.enabled = addonPrefs.expandSelectedObjsInOutliner 221 | row.prop(addonPrefs, "collapseUnselectedObjsInOutliner", expand=True) 222 | 223 | 224 | layout.separator() 225 | 226 | label = layout.label(text="Calculate Zoom based on:") 227 | zoomDistanceMethodRow = layout.row(align=True) 228 | zoomDistanceMethodRow.prop(addonPrefs, "calcZoomDistanceMethod", expand=True) 229 | 230 | layout.separator() 231 | 232 | frameObjType_sectionInner(self, context, scene, addonPrefs, False, layout) 233 | 234 | layout.separator() 235 | 236 | layout.prop(addonPrefs, "useAllRegionsWhenFraming", expand=True) 237 | layout.prop(addonPrefs, "useAll3DAreasWhenFraming", expand=True) 238 | 239 | layout.separator() 240 | 241 | layout.label(text="Max Vert Limit for Zoom Adjust:") 242 | layout.prop(addonPrefs, "maxVertAllowanceForZoomAdjust", expand=True) 243 | layout.prop(addonPrefs, "maxVertSelectionAllowanceForZoomAdjust", expand=True) 244 | 245 | 246 | 247 | def isolateOptions_sectionInner(self, context, scene, addonPrefs, layout): 248 | 249 | excludedObjsFromIsolate_sectionInner(self, context, scene, False, layout) 250 | 251 | layout.label(text="On Isolate, hide:") 252 | 253 | row = layout.row(align=True) 254 | 255 | row.prop(addonPrefs, "hideFloorOnIsolate", expand=True, text="Floor", toggle=True, icon="MESH_GRID") 256 | 257 | row.prop(addonPrefs, "hideAxesOnIsolate", expand=True, text="Axes", toggle=True, icon="EMPTY_AXIS") 258 | 259 | layout.separator() 260 | 261 | layout.prop(addonPrefs, "useExtremeHideOnIsolate", expand=True) 262 | 263 | 264 | 265 | 266 | 267 | 268 | def frameObjType_sectionInner(self, context, scene, addonPrefs, bIndent, layout): 269 | 270 | if bIndent: 271 | row = layout.row(align=True) 272 | indent = row.column(align=True) 273 | indent.label(text="", icon="BLANK1") 274 | 275 | frameObjTypeCol = row.column(align=True) 276 | else: 277 | frameObjTypeCol = layout 278 | 279 | frameObjTypeCol.label(text="When nothing is selected, frame:") 280 | 281 | grid = frameObjTypeCol.grid_flow(row_major=True, columns=2, align=True) 282 | 283 | for frameObjType in addonPrefs.frameObjTypeList: 284 | grid.prop(addonPrefs, frameObjType, expand=True, toggle=True) 285 | 286 | #END "When Nothing is selected, frame..." section 287 | 288 | def excludedObjsFromIsolate_sectionInner(self, context, scene, bIndent, layout): 289 | 290 | layout.separator() 291 | 292 | if bIndent: 293 | row = layout.row(align=True) 294 | indent = row.column(align=True) 295 | indent.label(text="", icon="BLANK1") 296 | 297 | excludedObjsFromIsolateCol = row.column(align=True) 298 | else: 299 | excludedObjsFromIsolateCol = layout 300 | 301 | excludedObjsFromIsolateCol.label(text="Excluded objects from Isolate:") 302 | excludedObjectsSection = excludedObjsFromIsolateCol.row(align=True) 303 | 304 | excludedObjectsSectionCol = excludedObjectsSection.column(align=True) 305 | 306 | numExcludedFromIsolate = len(scene.ntzSmFrm.excludedIsolateObjects) 307 | 308 | 309 | boxExcludedIsolate = excludedObjectsSectionCol.box() 310 | 311 | objectText = "objects" 312 | if numExcludedFromIsolate == 1: 313 | objectText = "object" 314 | 315 | text=f"{numExcludedFromIsolate} {objectText}." 316 | boxExcludedIsolate.label(text=text) 317 | 318 | boxCol = boxExcludedIsolate.column(align=True) 319 | 320 | if numExcludedFromIsolate > 0: 321 | 322 | if not scene.ntzSmFrm.hideFullIsolateExclusionList: 323 | row = boxCol.row(align=True) 324 | row.prop(scene.ntzSmFrm, "hideFullIsolateExclusionList", text="Show List", toggle=True) 325 | else: 326 | row = boxCol.row(align=True) 327 | row.prop(scene.ntzSmFrm, "hideFullIsolateExclusionList", text="Hide List", toggle=True) 328 | 329 | for item in scene.ntzSmFrm.excludedIsolateObjects: 330 | row = boxCol.row(align=True) 331 | 332 | op = row.operator('view3d.ntzsf_del_obj_from_excluded_isolate_objs', text="", icon="X") 333 | op.objectToUntemplate = item 334 | 335 | row.label(text=item) 336 | 337 | 338 | 339 | else: 340 | row = boxCol.row(align=True) 341 | row.label(text="None") 342 | 343 | excludedObjectsSectionCol = excludedObjectsSection.column(align=True) 344 | 345 | op = excludedObjectsSectionCol.operator('view3d.ntzsf_add_obj_to_excluded_isolate_objs', text="", icon="ADD") 346 | op = excludedObjectsSectionCol.operator('view3d.ntzsf_del_obj_from_excluded_isolate_objs', text="", icon="REMOVE") 347 | op = excludedObjectsSectionCol.operator('view3d.ntzsf_refresh_excluded_isolate_objs', text="", icon="FILE_REFRESH") 348 | op = excludedObjectsSectionCol.operator('view3d.ntzsf_clear_all_excluded_isolate_objs', text="", icon="TRASH") 349 | 350 | 351 | def templateOptions_section(self, context, scene, addonPrefs, bIndent, layout): 352 | 353 | layout.separator() 354 | 355 | if bIndent: 356 | row = layout.row(align=True) 357 | indent = row.column(align=True) 358 | indent.label(text="", icon="BLANK1") 359 | 360 | templatedObjsCol = row.column(align=True) 361 | else: 362 | templatedObjsCol = layout 363 | 364 | templatedObjsCol.label(text="Default Template Selectable State") 365 | prop = templatedObjsCol.prop(addonPrefs, 'defaultTemplateSelectableState', text="", toggle=True) 366 | 367 | templatedObjsCol.separator() 368 | 369 | templateSelectableCol = templatedObjsCol.column(align=True) 370 | templateSelectableCol.scale_y = 1.25 371 | templateSelectableCol.label(text="Make All Template Objects:") 372 | templateSelectableRow = templateSelectableCol.row(align=True) 373 | op = templateSelectableRow.operator('view3d.ntzsf_change_template_selection_state', text="Selectable", icon="NONE") 374 | op.makeSelectable = True 375 | 376 | op = templateSelectableRow.operator('view3d.ntzsf_change_template_selection_state', text="Un-selectable", icon="NONE") 377 | op.makeSelectable = False 378 | 379 | templatedObjsCol.separator() 380 | 381 | templatedObjsCol.label(text="Templated objects:") 382 | 383 | templatedObjectsSection = templatedObjsCol.row(align=True) 384 | templatedObjectsSectionCol = templatedObjectsSection.column(align=True) 385 | 386 | numTemplatedObjects = len(scene.ntzSmFrm.templatedObjects) 387 | 388 | boxTemplatedObjects = templatedObjectsSectionCol.box() 389 | 390 | objectText = "objects" 391 | if numTemplatedObjects == 1: 392 | objectText = "object" 393 | 394 | text=f"{numTemplatedObjects} {objectText}." 395 | boxTemplatedObjects.label(text=text) 396 | 397 | boxCol = boxTemplatedObjects.column(align=True) 398 | 399 | 400 | 401 | if numTemplatedObjects > 0: 402 | 403 | if not scene.ntzSmFrm.hideFullTemplateList: 404 | row = boxCol.row(align=True) 405 | row.prop(scene.ntzSmFrm, "hideFullTemplateList", text="Show List", toggle=True) 406 | else: 407 | row = boxCol.row(align=True) 408 | row.prop(scene.ntzSmFrm, "hideFullTemplateList", text="Hide List", toggle=True) 409 | 410 | for item in scene.ntzSmFrm.templatedObjects: 411 | row = boxCol.row(align=True) 412 | 413 | op = row.operator('view3d.ntzsf_untemplate_specific_obj', text="", icon="X") 414 | op.objectToUntemplate = item 415 | 416 | op = row.operator('view3d.ntzsf_sel_obj_by_name', text=item, icon="NONE", emboss=True) 417 | op.objToSelect = item 418 | 419 | selectState = bpy.data.objects[item] 420 | 421 | row.prop(bpy.data.objects[item], "hide_select", text="", emboss=False, invert_checkbox=True) 422 | 423 | 424 | 425 | else: 426 | row = boxCol.row(align=True) 427 | row.label(text="None") 428 | 429 | templatedObjectsSectionCol = templatedObjectsSection.column(align=True) 430 | 431 | op = templatedObjectsSectionCol.operator('view3d.ntzsf_convert_obj_to_template', text="", icon="ADD") 432 | 433 | if addonPrefs.defaultTemplateSelectableState == "UNSELECTABLE": 434 | op.makeSelectable = False 435 | elif addonPrefs.defaultTemplateSelectableState == "SELECTABLE": 436 | op.makeSelectable = True 437 | 438 | removeOpRow = templatedObjectsSectionCol.row(align=True) 439 | activeObj = bpy.context.view_layer.objects.active 440 | 441 | 442 | if activeObj is None: 443 | removeOpRow.enabled = False 444 | op = removeOpRow.operator('view3d.ntzsf_untemplate_objs', text="", icon="REMOVE") 445 | 446 | op = templatedObjectsSectionCol.operator('view3d.ntzsf_refresh_template_objs', text="", icon="FILE_REFRESH") 447 | op = templatedObjectsSectionCol.operator('view3d.ntzsf_clear_all_template_objs', text="", icon="TRASH") -------------------------------------------------------------------------------- /miscOt.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from . properties import ntzsf_scene_props 3 | from . import miscFunc 4 | 5 | from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty) 6 | from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup) 7 | 8 | # ----------------------------------------------------------------------------- 9 | # Add Object to Excluded Isolate Objects 10 | # ----------------------------------------------------------------------------- 11 | 12 | class VIEW3D_OT_ntzsf_add_obj_to_excluded_isolate_objs(Operator): 13 | """Tooltip""" 14 | bl_idname = "view3d.ntzsf_add_obj_to_excluded_isolate_objs" 15 | bl_label = 'NTZSF : Add obj to "Isolate Exclusion List"' 16 | bl_description = 'Add the object to the list of excluded isolated objects' 17 | bl_options = {'REGISTER', 'UNDO'} 18 | 19 | @classmethod 20 | def poll(cls, context): 21 | return True 22 | 23 | def execute(self, context): 24 | 25 | scene = context.scene 26 | selObjs = [obj for obj in bpy.context.selected_objects] 27 | 28 | for obj in selObjs: 29 | scene.ntzSmFrm.excludedIsolateObjects.add(obj.name) 30 | 31 | obj['ntzSmFrm_isolateExcluded'] = 1 32 | 33 | #Object added to the "excludedIsolateObjects" list 34 | 35 | return {'FINISHED'} 36 | # END execute() 37 | # END Operator() 38 | 39 | # ----------------------------------------------------------------------------- 40 | # Remove Object From Excluded Isolate Objects 41 | # ----------------------------------------------------------------------------- 42 | 43 | class VIEW3D_OT_ntzsf_del_obj_from_excluded_isolate_objs(Operator): 44 | """Tooltip""" 45 | bl_idname = "view3d.ntzsf_del_obj_from_excluded_isolate_objs" 46 | bl_label = 'NTZSF : Remove obj from "Isolate Exclusion List"' 47 | bl_description = 'Remove the object from the excluded isolated objects' 48 | bl_options = {'REGISTER', 'UNDO'} 49 | 50 | objectToUntemplate : StringProperty( 51 | name="Object to Remove", 52 | description="Name of the Object to remove (Default = None)", 53 | default = "None" 54 | ) 55 | 56 | @classmethod 57 | def poll(cls, context): 58 | return True 59 | 60 | def draw(self, context): 61 | pass 62 | #END draw() 63 | 64 | def execute(self, context): 65 | 66 | scene = context.scene 67 | 68 | if self.objectToUntemplate == "None": 69 | #User clicked the "-" button. Remove multiple objects that are selected 70 | 71 | selObjs = [obj for obj in bpy.context.selected_objects] 72 | 73 | for obj in selObjs: 74 | 75 | #if object name is in the scene list of excluded isolate objects, then remove it. 76 | if obj.name in scene.ntzSmFrm.excludedIsolateObjects: 77 | scene.ntzSmFrm.excludedIsolateObjects.remove(obj.name) 78 | 79 | #check to see if the prop "Neltulz_Isolate_Exlcluded" is on the selected object, if so, remove it. 80 | try: 81 | obj.pop('ntzSmFrm_isolateExcluded') 82 | except: 83 | pass 84 | else: 85 | #User clicked the "X" next to an object in the list of excluded objects from isolate. Remove the single object. 86 | obj = None 87 | try: 88 | obj = bpy.data.objects[self.objectToUntemplate] 89 | except: 90 | pass 91 | 92 | if obj is not None: 93 | #if object name is in the scene list of excluded isolate objects, then remove it. 94 | if obj.name in scene.ntzSmFrm.excludedIsolateObjects: 95 | scene.ntzSmFrm.excludedIsolateObjects.remove(obj.name) 96 | 97 | #check to see if the prop "Neltulz_Isolate_Exlcluded" is on the selected object, if so, remove it. 98 | try: 99 | obj.pop('ntzSmFrm_isolateExcluded') 100 | except: 101 | pass 102 | 103 | #removed custom property from object 104 | 105 | return {'FINISHED'} 106 | # END execute() 107 | # END Operator() 108 | 109 | # ----------------------------------------------------------------------------- 110 | # Refresh Excluded Isolate Objects 111 | # ----------------------------------------------------------------------------- 112 | 113 | class VIEW3D_OT_ntzsf_refresh_excluded_isolate_objs(Operator): 114 | """Tooltip""" 115 | bl_idname = "view3d.ntzsf_refresh_excluded_isolate_objs" 116 | bl_label = 'NTZSF : Refresh "Isolate Exclusion List"' 117 | bl_description = 'Refresh the list of excluded isolated objects. Useful if you have renamed objects and the list no longer matches' 118 | bl_options = {'REGISTER', 'UNDO'} 119 | 120 | @classmethod 121 | def poll(cls, context): 122 | return True 123 | 124 | def execute(self, context): 125 | 126 | scene = context.scene 127 | objs = [obj for obj in bpy.context.scene.objects] 128 | 129 | scene.ntzSmFrm.excludedIsolateObjects.clear() 130 | 131 | for obj in objs: 132 | 133 | try: 134 | if obj['ntzSmFrm_isolateExcluded']: 135 | scene.ntzSmFrm.excludedIsolateObjects.add(obj.name) 136 | except: 137 | pass 138 | 139 | 140 | 141 | #Refreshed 142 | 143 | return {'FINISHED'} 144 | # END execute() 145 | # END Operator() 146 | 147 | 148 | # ----------------------------------------------------------------------------- 149 | # Clear all Excluded Isolate Objects 150 | # ----------------------------------------------------------------------------- 151 | 152 | class VIEW3D_OT_ntzsf_clear_all_excluded_isolate_objs(Operator): 153 | """Tooltip""" 154 | bl_idname = "view3d.ntzsf_clear_all_excluded_isolate_objs" 155 | bl_label = 'NTZSF : Clear "Isolate Exclusion List"' 156 | bl_description = 'Clear the list of excluded isolated objects.' 157 | bl_options = {'REGISTER', 'UNDO'} 158 | 159 | @classmethod 160 | def poll(cls, context): 161 | return True 162 | 163 | def execute(self, context): 164 | 165 | scene = context.scene 166 | objs = [obj for obj in bpy.context.scene.objects] 167 | 168 | scene.ntzSmFrm.excludedIsolateObjects.clear() 169 | 170 | for obj in objs: 171 | try: 172 | obj.pop('ntzSmFrm_isolateExcluded') 173 | except: 174 | pass 175 | 176 | 177 | 178 | #Cleared 179 | 180 | return {'FINISHED'} 181 | # END execute() 182 | # END Operator() 183 | 184 | # ----------------------------------------------------------------------------- 185 | # Template (Converts object to wireframe with click-through) 186 | # ----------------------------------------------------------------------------- 187 | 188 | class VIEW3D_OT_ntzsf_convert_obj_to_template(Operator): 189 | """Tooltip""" 190 | bl_idname = "view3d.ntzsf_convert_obj_to_template" 191 | bl_label = 'NTZSF : Add obj to "Templated Obj List"' 192 | bl_description = 'Converts object to wireframe with click-through' 193 | bl_options = {'REGISTER', 'UNDO'} 194 | 195 | makeSelectable : BoolProperty ( 196 | name="Make Template Selectable", 197 | description="Make the template object selectable (Default = False)", 198 | default = False 199 | ) 200 | 201 | @classmethod 202 | def poll(cls, context): 203 | return True 204 | 205 | def execute(self, context): 206 | 207 | scene = context.scene 208 | activeObj = bpy.context.view_layer.objects.active 209 | 210 | modeAtBegin = "Unknown" #declare 211 | try: 212 | #try to determine objectMode 213 | modeAtBegin = bpy.context.object.mode 214 | except: 215 | modeAtBegin = "OBJECT" 216 | 217 | selObjs = miscFunc.getSelObjsFromOutlinerAndViewport(self, context, modeAtBegin) 218 | 219 | for obj in selObjs: 220 | scene.ntzSmFrm.templatedObjects.add(obj.name) 221 | 222 | templateEnabled = False 223 | 224 | try: 225 | if obj['ntzSmFrm_template']: 226 | objIsTemplate = True 227 | except: 228 | pass 229 | 230 | if not templateEnabled: 231 | obj['ntzSmFrm_originalDisplay'] = obj.display_type 232 | obj.display_type = 'WIRE' 233 | obj.hide_select = True 234 | obj['ntzSmFrm_template'] = 1 235 | 236 | #Templated 237 | 238 | return {'FINISHED'} 239 | # END execute() 240 | # END Operator() 241 | 242 | 243 | # ----------------------------------------------------------------------------- 244 | # Toggle Template of objects highlighted in outliner 245 | # ----------------------------------------------------------------------------- 246 | 247 | class VIEW3D_OT_ntzsf_toggle_template(Operator): 248 | """Tooltip""" 249 | bl_idname = "view3d.ntzsf_toggle_template" 250 | bl_label = 'NTZSF : Template' 251 | bl_description = 'Toggles object(s) between template and non template' 252 | bl_options = {'REGISTER', 'UNDO'} 253 | 254 | tooltip: bpy.props.StringProperty() 255 | 256 | makeSelectable : BoolProperty ( 257 | name="Make Template Selectable", 258 | description="Make the template object selectable (Default = False)", 259 | default = False 260 | ) 261 | 262 | @classmethod 263 | def poll(cls, context): 264 | return True 265 | 266 | @classmethod 267 | def description(cls, context, properties): 268 | return properties.tooltip 269 | 270 | 271 | def draw(self, context): 272 | scene = context.scene 273 | lay = self.layout.column(align=True) 274 | 275 | lay.prop(self, 'makeSelectable') 276 | #END draw() 277 | 278 | def execute(self, context): 279 | 280 | scene = context.scene 281 | 282 | modeAtBegin = "Unknown" #declare 283 | 284 | try: 285 | #try to determine objectMode 286 | modeAtBegin = bpy.context.object.mode 287 | except: 288 | modeAtBegin = "OBJECT" 289 | 290 | selObjs = miscFunc.getSelObjsFromOutlinerAndViewport(self, context, modeAtBegin) 291 | 292 | if modeAtBegin == "OBJECT": 293 | if len(selObjs) > 0: 294 | for obj in selObjs: 295 | bpy.context.view_layer.objects.active = obj 296 | break 297 | 298 | for obj in selObjs: 299 | objIsTemplate = False #declare 300 | 301 | try: 302 | if obj['ntzSmFrm_template']: 303 | objIsTemplate = True 304 | except: 305 | pass 306 | 307 | if objIsTemplate: 308 | bpy.ops.view3d.ntzsf_untemplate_specific_obj(objectToUntemplate = f"{obj.name}" ) 309 | else: 310 | bpy.ops.view3d.ntzsf_template_specific_obj(objectToTemplate = f"{obj.name}", makeSelectable = self.makeSelectable ) 311 | 312 | 313 | #Templated 314 | 315 | return {'FINISHED'} 316 | # END execute() 317 | 318 | 319 | def invoke(self, context, event): 320 | 321 | addonPrefs = context.preferences.addons[__package__].preferences 322 | 323 | if addonPrefs.defaultTemplateSelectableState == "UNSELECTABLE": 324 | self.makeSelectable = False 325 | elif addonPrefs.defaultTemplateSelectableState == "SELECTABLE": 326 | self.makeSelectable = True 327 | 328 | return self.execute(context) 329 | #END invoke() 330 | # END Operator() 331 | 332 | 333 | # ----------------------------------------------------------------------------- 334 | # Refresh Templated Objects List 335 | # ----------------------------------------------------------------------------- 336 | 337 | class VIEW3D_OT_ntzsf_refresh_template_objs(Operator): 338 | """Tooltip""" 339 | bl_idname = "view3d.ntzsf_refresh_template_objs" 340 | bl_label = 'NTZSF : Refresh "Templated Obj List"' 341 | bl_description = 'Refresh the list of templated objects' 342 | bl_options = {'REGISTER', 'UNDO'} 343 | 344 | @classmethod 345 | def poll(cls, context): 346 | return True 347 | 348 | def execute(self, context): 349 | 350 | scene = context.scene 351 | objs = [obj for obj in bpy.context.scene.objects] 352 | 353 | scene.ntzSmFrm.templatedObjects.clear() 354 | 355 | for obj in objs: 356 | 357 | try: 358 | if obj['ntzSmFrm_template']: 359 | scene.ntzSmFrm.templatedObjects.add(obj.name) 360 | except: 361 | pass 362 | 363 | 364 | 365 | #Refreshed Template Objects 366 | 367 | return {'FINISHED'} 368 | # END execute() 369 | # END Operator() 370 | 371 | 372 | # ----------------------------------------------------------------------------- 373 | # Un-Template Highlighted Objects in the Outliner 374 | # ----------------------------------------------------------------------------- 375 | 376 | class VIEW3D_OT_ntzsf_untemplate_objs(Operator): 377 | """Tooltip""" 378 | bl_idname = "view3d.ntzsf_untemplate_objs" 379 | bl_label = 'NTZSF : Remove obj from "Templated Obj List"' 380 | bl_description = 'Remove the templated object' 381 | bl_options = {'REGISTER', 'UNDO'} 382 | 383 | @classmethod 384 | def poll(cls, context): 385 | return True 386 | 387 | def execute(self, context): 388 | scene = context.scene 389 | selObjsInOutliner = [] #declare 390 | 391 | # Select objects in outliner 392 | area = None #declare 393 | try: 394 | #check for outliner in the main window 395 | area = next(a for a in context.screen.areas if a.type == 'OUTLINER') 396 | except: 397 | try: 398 | #check for outliner in other windows 399 | area = next(a for w in context.window_manager.windows 400 | for a in w.screen.areas if a.type == 'OUTLINER') 401 | except: 402 | pass 403 | 404 | if area is not None: 405 | sel_org = context.selected_objects[:] 406 | objs = context.view_layer.objects 407 | 408 | hide_select = {o for o in objs if o.hide_select} 409 | for o in hide_select: # Toggle off hide select 410 | o.hide_select = False 411 | 412 | for o in sel_org: # Deselect all selected 413 | o.select_set(False) 414 | 415 | bpy.ops.outliner.object_operation({'area': area}, type='SELECT') 416 | 417 | selObjsInOutliner = context.selected_objects[:] 418 | 419 | # Toggle on hide select for objects not selected in outliner 420 | for o in hide_select: 421 | if not o.select_get(): 422 | o.hide_select = True 423 | 424 | for o in sel_org: # Restore original selection 425 | o.select_set(True) 426 | 427 | 428 | # BEGIN code that un-templates the object 429 | 430 | for obj in selObjsInOutliner: 431 | templateEnabled = obj.pop("ntzSmFrm_template", False) 432 | originalDisplay = obj.pop('ntzSmFrm_originalDisplay', "SOLID") 433 | 434 | if templateEnabled: 435 | obj.display_type = originalDisplay 436 | obj.hide_select = False 437 | scene.ntzSmFrm.templatedObjects.discard( f"{obj.name}" ) 438 | 439 | # END code that un-templates the object 440 | 441 | return {'FINISHED'} 442 | # END execute() 443 | # END Operator() 444 | 445 | # ----------------------------------------------------------------------------- 446 | # Template Specific Obj 447 | # ----------------------------------------------------------------------------- 448 | 449 | class VIEW3D_OT_ntzsf_template_specific_obj(Operator): 450 | """Tooltip""" 451 | bl_idname = "view3d.ntzsf_template_specific_obj" 452 | bl_label = 'NTZSF : Add specific obj from "Templated Obj List"' 453 | bl_description = 'Add specific object from templated object list' 454 | bl_options = {'REGISTER', 'UNDO'} 455 | 456 | objectToTemplate : StringProperty( 457 | name="Object to Template", 458 | description="Name of the Object to Template (Default = None)", 459 | default = "None" 460 | ) 461 | 462 | makeSelectable : BoolProperty ( 463 | name="Make Template Selectable", 464 | description="Make the template object selectable (Default = False)", 465 | default = False 466 | ) 467 | 468 | @classmethod 469 | def poll(cls, context): 470 | return True 471 | 472 | def execute(self, context): 473 | scene = context.scene 474 | 475 | # BEGIN code that templates the object 476 | 477 | obj = None #declare 478 | try: 479 | obj = bpy.data.objects[self.objectToTemplate] 480 | except: 481 | pass 482 | 483 | if obj is not None: 484 | scene.ntzSmFrm.templatedObjects.add(obj.name) 485 | 486 | templateEnabled = False 487 | 488 | try: 489 | if obj['ntzSmFrm_template']: 490 | templateEnabled = True 491 | except: 492 | pass 493 | 494 | if not templateEnabled: 495 | obj['ntzSmFrm_originalDisplay'] = obj.display_type 496 | obj.display_type = 'WIRE' 497 | 498 | obj.hide_select = not(self.makeSelectable) 499 | obj['ntzSmFrm_template'] = 1 500 | 501 | # END code that templates the object 502 | 503 | 504 | return {'FINISHED'} 505 | # END execute() 506 | # END Operator() 507 | 508 | 509 | # ----------------------------------------------------------------------------- 510 | # Un-Template Specific Obj 511 | # ----------------------------------------------------------------------------- 512 | 513 | class VIEW3D_OT_ntzsf_untemplate_specific_obj(Operator): 514 | """Tooltip""" 515 | bl_idname = "view3d.ntzsf_untemplate_specific_obj" 516 | bl_label = 'NTZSF : Remove specific obj from "Templated Obj List"' 517 | bl_description = 'Remove specific object from templated object list' 518 | bl_options = {'REGISTER', 'UNDO'} 519 | 520 | objectToUntemplate : StringProperty( 521 | name="Object to Remove", 522 | description="Name of the Object to remove (Default = None)", 523 | default = "None" 524 | ) 525 | 526 | @classmethod 527 | def poll(cls, context): 528 | return True 529 | 530 | def draw(self, context): 531 | pass 532 | #END draw() 533 | 534 | def execute(self, context): 535 | scene = context.scene 536 | 537 | # BEGIN code that un-templates the object 538 | 539 | obj = None #declare 540 | try: 541 | obj = bpy.data.objects[self.objectToUntemplate] 542 | except: 543 | pass 544 | 545 | if obj is not None: 546 | templateEnabled = obj.pop("ntzSmFrm_template", False) 547 | originalDisplay = obj.pop('ntzSmFrm_originalDisplay', "SOLID") 548 | 549 | if templateEnabled: 550 | obj.display_type = originalDisplay 551 | obj.hide_select = False 552 | scene.ntzSmFrm.templatedObjects.discard( self.objectToUntemplate ) 553 | 554 | # END code that un-templates the object 555 | 556 | 557 | return {'FINISHED'} 558 | # END execute() 559 | # END Operator() 560 | 561 | 562 | 563 | # ----------------------------------------------------------------------------- 564 | # Clear all Templated Objects 565 | # ----------------------------------------------------------------------------- 566 | 567 | class VIEW3D_OT_ntzsf_clear_all_template_objs(Operator): 568 | """Tooltip""" 569 | bl_idname = "view3d.ntzsf_clear_all_template_objs" 570 | bl_label = 'NTZSF : Clear "Templated Obj List"' 571 | bl_description = 'Clear the list of templated objects' 572 | bl_options = {'REGISTER', 'UNDO'} 573 | 574 | @classmethod 575 | def poll(cls, context): 576 | return True 577 | 578 | def execute(self, context): 579 | 580 | scene = context.scene 581 | objs = [obj for obj in bpy.context.scene.objects] 582 | 583 | scene.ntzSmFrm.templatedObjects.clear() 584 | 585 | 586 | 587 | for obj in objs: 588 | 589 | templateEnabled = obj.pop("ntzSmFrm_template", False) 590 | originalDisplay = obj.pop('ntzSmFrm_originalDisplay', "SOLID") 591 | 592 | if templateEnabled: 593 | obj.display_type = originalDisplay 594 | obj.hide_select = False 595 | 596 | #Cleared Template Objects 597 | 598 | return {'FINISHED'} 599 | # END execute() 600 | # END Operator() 601 | 602 | 603 | # ----------------------------------------------------------------------------- 604 | # Make all existing template objects selectable 605 | # ----------------------------------------------------------------------------- 606 | 607 | class VIEW3D_OT_ntzsf_change_template_selection_state(Operator): 608 | """Tooltip""" 609 | bl_idname = "view3d.ntzsf_change_template_selection_state" 610 | bl_label = 'NTZSF : Change All Template Selection State' 611 | bl_description = 'Change All Template Selection State' 612 | bl_options = {'REGISTER', 'UNDO'} 613 | 614 | makeSelectable : BoolProperty( 615 | name="Make All Objects Selectable", 616 | description="Make All Objects Selectable", 617 | default = True 618 | ) 619 | 620 | @classmethod 621 | def poll(cls, context): 622 | return True 623 | 624 | def execute(self, context): 625 | 626 | #refresh templated obj list 627 | bpy.ops.view3d.ntzsf_refresh_template_objs() 628 | 629 | scene = context.scene 630 | objs = [obj for obj in bpy.context.scene.objects] 631 | 632 | for obj in objs: 633 | 634 | templateEnabled = False 635 | try: 636 | if obj['ntzSmFrm_template']: 637 | templateEnabled = True 638 | except: 639 | pass 640 | 641 | if templateEnabled: 642 | if self.makeSelectable: 643 | obj.hide_select = False 644 | else: 645 | obj.hide_select = True 646 | 647 | #Cleared Template Objects 648 | 649 | return {'FINISHED'} 650 | # END execute() 651 | # END Operator() 652 | 653 | # ----------------------------------------------------------------------------- 654 | # Select Object by Name 655 | # ----------------------------------------------------------------------------- 656 | 657 | class VIEW3D_OT_ntzsf_sel_obj_by_name(Operator): 658 | """Tooltip""" 659 | bl_idname = "view3d.ntzsf_sel_obj_by_name" 660 | bl_label = 'NTZSF : Select Object' 661 | bl_description = 'Selects and object by name' 662 | bl_options = {'REGISTER', 'UNDO'} 663 | 664 | objToSelect : StringProperty( 665 | name="Object to Select", 666 | description="Name of the Object to Select (Default = None)", 667 | default = "None" 668 | ) 669 | 670 | @classmethod 671 | def poll(cls, context): 672 | return True 673 | 674 | def draw(self, context): 675 | pass 676 | #END draw() 677 | 678 | def execute(self, context): 679 | 680 | scene = context.scene 681 | 682 | modeAtBegin = "Unknown" #declare 683 | try: 684 | #try to determine objectMode 685 | modeAtBegin = bpy.context.object.mode 686 | except: 687 | modeAtBegin = "OBJECT" 688 | 689 | 690 | obj = None 691 | try: 692 | obj = bpy.data.objects[self.objToSelect] 693 | except: 694 | pass 695 | 696 | if obj is not None: 697 | 698 | if modeAtBegin == "EDIT": 699 | bpy.ops.object.mode_set(mode = 'OBJECT') #switch to object mode 700 | 701 | bpy.ops.object.select_all(action='DESELECT') #deselect all objs 702 | obj.select_set(True) #select object 703 | bpy.context.view_layer.objects.active = obj #set obj as active obj 704 | 705 | 706 | return {'FINISHED'} 707 | # END execute() 708 | # END Operator() -------------------------------------------------------------------------------- /panels.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from . properties import ntzsf_scene_props 3 | from . import miscFunc 4 | from . import miscLay 5 | 6 | from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty) 7 | from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup, Menu) 8 | 9 | # ----------------------------------------------------------------------------- 10 | # Panel 11 | # ----------------------------------------------------------------------------- 12 | 13 | class VIEW3D_PT_ntzsf_frame_options(Panel): 14 | bl_label = "Neltulz - Frame Options" 15 | bl_idname = "VIEW3D_PT_ntzsf_frame_options" 16 | bl_category = "" 17 | bl_space_type = "VIEW_3D" 18 | bl_region_type = "WINDOW" 19 | 20 | def draw(self, context): 21 | scene = context.scene 22 | layout = self.layout 23 | layout.ui_units_x = 15 24 | 25 | frameOptionsSection = layout.column(align=True) 26 | 27 | addonPrefs = context.preferences.addons[__package__].preferences 28 | 29 | miscLay.frameOptions_sectionInner(self, context, scene, addonPrefs, frameOptionsSection) 30 | 31 | #END draw() 32 | 33 | 34 | class VIEW3D_PT_ntzsf_isolate_options(Panel): 35 | bl_label = "Neltulz - Isolate Options" 36 | bl_idname = "VIEW3D_PT_ntzsf_isolate_options" 37 | bl_category = "" 38 | bl_space_type = "VIEW_3D" 39 | bl_region_type = "WINDOW" 40 | 41 | def draw(self, context): 42 | scene = context.scene 43 | layout = self.layout 44 | layout.ui_units_x = 15 45 | 46 | isolateOptionsSection = layout.column(align=True) 47 | 48 | addonPrefs = context.preferences.addons[__package__].preferences 49 | 50 | miscLay.isolateOptions_sectionInner(self, context, scene, addonPrefs, isolateOptionsSection) 51 | 52 | #END draw() 53 | 54 | class VIEW3D_PT_ntzsf_tmpl_options(Panel): 55 | bl_label = "Neltulz - Isolate Options" 56 | bl_idname = "VIEW3D_PT_ntzsf_tmpl_options" 57 | bl_category = "" 58 | bl_space_type = "VIEW_3D" 59 | bl_region_type = "WINDOW" 60 | 61 | def draw(self, context): 62 | scene = context.scene 63 | layout = self.layout 64 | layout.ui_units_x = 15 65 | 66 | templateOptionsSection = layout.column(align=True) 67 | 68 | addonPrefs = bpy.context.preferences.addons[__package__].preferences 69 | 70 | miscLay.templateOptions_section(self, context, scene, addonPrefs, False, templateOptionsSection) 71 | 72 | #END draw() 73 | 74 | class VIEW3D_PT_ntzsf_options(Panel): 75 | bl_label = "Neltulz - Options" 76 | bl_idname = "VIEW3D_PT_ntzsf_options" 77 | bl_category = "" 78 | bl_space_type = "VIEW_3D" 79 | bl_region_type = "WINDOW" 80 | 81 | def draw(self, context): 82 | scene = context.scene 83 | layout = self.layout 84 | layout.ui_units_x = 12 85 | 86 | optionsSection = layout.column(align=True) 87 | 88 | miscLay.options_sectionInner(self, context, scene, True, False, False, False, optionsSection) 89 | 90 | #END draw() 91 | 92 | 93 | 94 | class VIEW3D_PT_ntzsf_sb_panel(Panel): 95 | bl_label = "Smart Frame v1.0.16" 96 | bl_category = "Neltulz" 97 | bl_space_type = "VIEW_3D" 98 | bl_region_type = "UI" 99 | 100 | bUseCompactSidebarPanel = BoolProperty( 101 | name="Use Compact Panel", 102 | description="Use Compact Panel", 103 | default = False 104 | ) 105 | 106 | bUseCompactPopupAndPiePanel = BoolProperty( 107 | name="Use Compact Popup & Pie Panel", 108 | description="Use Compact Popup & Pie Panel", 109 | default = True 110 | ) 111 | 112 | def draw(self, context): 113 | miscLay.mainSmartFramePanel(self, context, self.bUseCompactSidebarPanel, self.bUseCompactPopupAndPiePanel) 114 | #END draw() -------------------------------------------------------------------------------- /properties.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | from . import miscFunc 3 | 4 | from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty) 5 | from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup) 6 | 7 | 8 | class ntzsf_scene_props(bpy.types.PropertyGroup): 9 | 10 | preventInfiniteRecursion : BoolProperty ( 11 | name="Prevent Infinite Recursion", 12 | description="Reveals options.", 13 | default = False, 14 | ) 15 | 16 | bShowOptions : BoolProperty ( 17 | name="Show Options", 18 | description="Reveals options.", 19 | default = False, 20 | ) 21 | 22 | 23 | 24 | bShowFrameObjTypes : BoolProperty ( 25 | name="Show Frame Object Types", 26 | description="Show Frame Object Types.", 27 | default = True, 28 | ) 29 | 30 | bShowExcludedObjFromIsolateTypes : BoolProperty ( 31 | name="Show Excluded Object From Isolate Types", 32 | description="Show Excluded Object From Isolate Types.", 33 | default = True, 34 | ) 35 | 36 | bShowTemplatedObjs : BoolProperty ( 37 | name="Show Templated Objects", 38 | description="Show Templated Objects", 39 | default = True, 40 | ) 41 | 42 | useAdvancedSettings : BoolProperty( 43 | name="Use Advanced Settings", 44 | description="Use advanced settings (Default: False)", 45 | default = False 46 | ) 47 | 48 | optionsPopoverEnum : EnumProperty ( 49 | items = [("OPTIONS", "Options", "", "", 0)], 50 | name = "Options Popover Enum", 51 | description = "Options Popover Enum", 52 | default = "OPTIONS" 53 | ) 54 | 55 | frameObjType : EnumProperty ( 56 | items = [("OBJTYPE", "Object Types", "", "", 0)], 57 | name = "Frame Object Types", 58 | description = "Frame Object Types", 59 | default = "OBJTYPE" 60 | ) 61 | 62 | currentlyBusyIsolating : BoolProperty( 63 | name="Currently Busy Isolating", 64 | description="Currently busy isolating (Default: False)", 65 | default = False 66 | ) 67 | 68 | hideFullIsolateExclusionList : BoolProperty( 69 | name="Hide All", 70 | description="Hide the entire list of excluded objects from isolate", 71 | default = True 72 | ) 73 | 74 | hideFullTemplateList : BoolProperty( 75 | name="Hide All", 76 | description="Hide the entire list of templated objects", 77 | default = True 78 | ) 79 | 80 | 81 | floorWasPreviouslyVisible : BoolProperty( 82 | name="Previous Floor Visibility", 83 | description="Floor was visible before user entered isolate mode (Default: False)", 84 | default = False 85 | ) 86 | 87 | axis_x_wasPreviouslyVisible : BoolProperty( 88 | name="Previous X Axis Visibility", 89 | description="X Axis was visible before user entered isolate mode (Default: False)", 90 | default = False 91 | ) 92 | 93 | axis_y_wasPreviouslyVisible : BoolProperty( 94 | name="Previous Y Axis Visibility", 95 | description="Y Axis was visible before user entered isolate mode (Default: False)", 96 | default = False 97 | ) 98 | 99 | axis_z_wasPreviouslyVisible : BoolProperty( 100 | name="Previous Z Axis Visibility", 101 | description="Z Axis was visible before user entered isolate mode (Default: False)", 102 | default = False 103 | ) 104 | 105 | hideErrorMessages : BoolProperty( 106 | name="Hide Error Messages", 107 | description="Hide Error Messages (Default: False)", 108 | default = False 109 | ) 110 | 111 | 112 | 113 | excludedIsolateObjects = set() 114 | templatedObjects = set() --------------------------------------------------------------------------------