Using the skills learned in chapter 3, this video quickly demonstrates how to append this new operator to the shift-A add object menu for quick access. Similar to appending new layout elements to a blender panel, it is important to properly define the register and un-register functions corresponding with the enabling and disabling of the add-on.
- [Instructor] As the next step,…let's now complete the code…that allows us to put the operator…in the Shift + A 3D view menu.…If we scroll down to line 51,…we can uncomment the templated function…that is our add_object_button.…As a reminder, this is the function that's going…to be appended to the existing Blender-defined menu…in order to draw the additional operator.…Firstly, we need to be sure we pass in self…as well as context, to this draw function,…and then end the line with a colon.…Next, we simply need to define the one operator…that's gonna be part of this draw function.…
We can do this using self.layout.operator,…and then, in this case we can use a multi-line definition…so I'm gonna press Enter, and then Tab twice…to create two levels of indentation,…to increase readability,…and then we need to add in the BLID name.…Now as you may recall,…we can either add in the string of the BLID name,…which was mesh.add smooth monkey,…but a better practice is you add in the class name…and then reference the BL label as a class variable.…
AuthorPatrick W. Crawford
- Controlling Blender with code
- Exploring the bpy library
- Creating Blender operators and properties
- Writing scripts
- Auto running scripts
- Drawing interface elements such as panels and menus
- Building a custom add-on
Skill Level Intermediate
1. Controlling Blender through Code
2. Create Blender Scripts
3. Customize Blender Interfaces
4. Build Your Own Add-On
Next steps1m 15s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.