Films Training Blog
Pipeline and Tools Characters
Pipeline and Tools Characters
search Login Join
favorite

Development Fund

Support Blender Core Development with a monthly contribution.

theaters

Blender Studio

The creators who share. Access production content and knowledge from the Open Movies.

code

Blender Developer Blog

Latest news and updates on Blender development.

people

Get Involved

Join the community and help with design, development, docs and more.

bar_chart

Open Data

A platform to collect and display the Blender Benchmark results.

menu_book

Blender Docs

Documentation on Blender's features, tools and API.

Blender Conference

The yearly event that brings together the Blender community in one place.

download

Get Blender

Download the latest Blender version, or try the beta!

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

25th April 2020

info License: CC-BY Free
Download (117.2 MB)
Download English Subtitles
flag Report Problem

Published by

Sybren A. Stüvel

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

3 Comments

Join to comment publicly.

Samuel Bernou

26th April 2020 - 15:36

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

28th April 2020 - 10:12

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

Samuel Bernou

2nd May 2020 - 14:45

*@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 ;)

Blender Studio

The Creators Who Share.

Facebook Logo Twitter Logo YouTube Logo
  • Films
  • Blog
  • Training
Pipeline and Tools
  • Cloud Rig
  • Blender Kitsu
  • Contact Sheet Add-on
  • Blender Purge
  • Blender Cloud Services
Characters
  • Einar
  • Security Bot
  • Huginn
  • Pack Bot
Studio
  • Terms & Conditions
  • Privacy Policy
  • Contact
  • Remixing Music
  • Blender.org
Loading...