Blender Studio
  • Films
  • Training
  • Characters
  • Pipeline
  • Blog
  • Sign in
  • Join
  • BLENDER.ORG

    • Download

      Get the latest Blender, older versions, or experimental builds.

    • What's New

      Stay up-to-date with the new features in the latest Blender releases.

    LEARNING & RESOURCES

    • Blender Studio

      Access production assets and knowledge from the open movies.

    • Manual

      Documentation on the usage and features in Blender.

    DEVELOPMENT

    • Developers Blog

      Latest development updates, by Blender developers.

    • Documentation

      Guidelines, release notes and development docs.

    • Benchmark

      A platform to collect and share results of the Blender Benchmark.

    • Blender Conference

      The yearly event that brings the community together.

    DONATE

    • Development Fund

      Support core development with a monthly contribution.

    • One-time Donations

      Perform a single donation with more payment options available.

Films
Training
Blog
Pipeline and Tools
Characters
Search
Login
Join

Course

Scripting for Artists
feed Course Overview
feed Blender Versions
Videos keyboard_arrow_down
  1. 01

    Introduction & copy-pasting

    Free
  2. 02

    Names & Objects

  3. 03

    Stuff on Lists

  4. 04

    Data Types

  5. 05

    Collections: Mass-Rename of Objects

  6. 06

    Blender Collections

    Free
  7. 07

    For vs. While

    Free
  8. 08

    Your Own Operator

    Free
  9. 09

    From Script to Add-on

    Free
  10. 10

    User Interfaces

    Free
  11. 11

    Custom Properties

    Free
  12. 12

    Asset Linking

    Free
  13. 13

    Roast my Add-on

    Free
  14. 14

    The Roast of Nature Clicker

    Free
  15. 15

    Modal Operators

    Free
  16. 16

    Readability & Understandability

Tech keyboard_arrow_down
  1. 01

    Updating F-Curves

  2. 02

    Render 10,000 OBJ files

  3. 03

    Mass-Rename Bones & Vertex Groups

  4. 04

    Rendering from 'all' angles

Course

Scripting for Artists
feed Blender Versions
Videos keyboard_arrow_down
  1. 01

    Introduction & copy-pasting

    Free
  2. 02

    Names & Objects

  3. 03

    Stuff on Lists

  4. 04

    Data Types

  5. 05

    Collections: Mass-Rename of Objects

  6. 06

    Blender Collections

    Free
  7. 07

    For vs. While

    Free
  8. 08

    Your Own Operator

    Free
  9. 09

    From Script to Add-on

    Free
  10. 10

    User Interfaces

    Free
  11. 11

    Custom Properties

    Free
  12. 12

    Asset Linking

    Free
  13. 13

    Roast my Add-on

    Free
  14. 14

    The Roast of Nature Clicker

    Free
  15. 15

    Modal Operators

    Free
  16. 16

    Readability & Understandability

Tech keyboard_arrow_down
  1. 01

    Updating F-Curves

  2. 02

    Render 10,000 OBJ files

  3. 03

    Mass-Rename Bones & Vertex Groups

  4. 04

    Rendering from 'all' angles

Videos

Custom Properties

April 25th, 2020

info License: CC-BY Free
Download (117.2 MB)
Download English Subtitles
Report Problem
Sybren A. Stüvel
Sybren A. Stüvel Publisher

Custom Properties allow you to attach your own data to things in Blender. In this episode of Scripting for Artists Sybren shows how to create an importer that loads all OBJ files in a directory, and then allows reloading OBJ files with the click of a button.

  • Different kind of properties: 00:24
  • Starting a new add-on with empty panel: 01:14
  • Adding a property to the scene: 03:36
  • Setting property subtypes: 06:35
  • Drawing the property in a panel: 08:03
  • Creating mass-importing operator: 08:51
  • Adding a property to all objects: 10:09
  • Importing OBJ files: 11:54
  • Re-importing OBJ files: 15:22
  • Deleting objects from the scene: 17:15
  • Moving code into a function: 19:!2

Join to comment publicly.

3 comments

Samuel Bernou
Samuel Bernou April 26th, 2020

Super cool ! Thank you for the list copy trick when iterating while altering the content !

Question about custom properties. Can they store a specific blender object type (or a pointer to a specific blender object !?).
Exemple for my use case on an active grease pencil object:

>>> bpy.context.object.data.layers['Lines'].frames[0].strokes[1]
bpy.data.grease_pencils['Suzanne']...GPencilStroke

I want to store direct access to this stroke, because data_path has good chance to become invalid (layer name can change, as for both frame and stroke index).
If I assign this in a variable it works well for the curent session, but once I save and reload/revert the file I lost the references... Is there a way to store this type using properties ?

Sybren A. Stüvel
Sybren A. Stüvel April 28th, 2020

*@Samuel Bernou* You could have a look at bpy.props.PointerProperty, that might do what you need.

Samuel Bernou
Samuel Bernou May 2nd, 2020

*@Sybren A. Stüvel* Ok, I tried with a pointer prop, but I obviously don't understand how it work (or maybe it's not possible with GP strokes)

>>> strokeid_3 = C.object.data.layers.active.active_frame.strokes[3].rna_type
>>> bpy.types.Scene.three = bpy.props.PointerProperty(type = strokeid_3, name = "three")
TypeError: PointerProperty(...) expected an RNA type, failed with type 'GPencilStroke'
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
ValueError: bpy_struct "Scene" registration error: three could not register

But yeah PointerProperty would have been the way to go. Thank you for pointing this ;)

  • Films
  • Training
  • Blog
Pipeline and Tools
  • Cloud Rig
  • Blender Kitsu
  • Contact Sheet Add-on
  • Blender Purge
  • Blender Cloud Services
Characters
  • Cat
  • Dog
  • Chicken & Sets
  • Einar
Studio
  • Terms & Conditions
  • Privacy Policy
  • Contact
  • Remixing Music
  • blender.org

Blender Studio

The creators who share.

Facebook Logo Twitter Logo YouTube Logo
Loading...