2
$\begingroup$

I'm writing a tool with a very simple panel with buttons.

On pressing a button a custom property with a specific name is to be assigned to the active object.

The UI should have 2 buttons Target and Clear

  • Pressing Target button in the UI should create a custom property.
  • Pressing Clear button in the UI should delete customer property that was created by the Target button (if such customer property is present).

For example, I have Cube and Sphere (names) objects. I would select Cube, then Sphere, press Target button, and Cube will have custom property names "target" with value "Sphere".

Selecting both of them in any manner and pressing Clear button would remove that custom property.

How do I go about making such basic add-on?

EDIT: Here is a mock-up that should explain it all :)

enter image description here

Link to full screen image: https://i.stack.imgur.com/aWyLc.png

$\endgroup$
1
  • $\begingroup$ Question isnt really clear about whats needed, is this about creating custom properties, or creating UI's?... How do I write an addon that does ***** is likely too vague for a question. Also did you try to do this already? - if so, what was the issue that stopped you from getting it working? $\endgroup$
    – ideasman42
    Jul 19, 2015 at 23:04

3 Answers 3

2
$\begingroup$

The question seems to be asking for an add-on to be written from scratch? which is too specific.

The answer is yes, this is possible.

  • Create an addon (see addon template).
  • Create a panel, (see template for making a panel).
  • Create an operator (see templates for creating those)
  • The operator can assign a custom property, see the Quick Start section on Custom Properties

So all of this is documented, best try to put this together to write your add-on.

Note, to access templates, see:
Text Editor (Header) -> Templates -> Python

$\endgroup$
2
  • $\begingroup$ Where do I find all the templates and documentation? $\endgroup$
    – motorsep
    Jul 19, 2015 at 23:59
  • $\begingroup$ Edited answer to include "how to access templates". $\endgroup$
    – ideasman42
    Jul 20, 2015 at 1:17
5
$\begingroup$

you want ID properties, they can be set per object

obj = bpy.data.objects['whatever']
obj['some_property_name'] = 'some_value'
obj['some_property_name_2'] = 33

>>> obj['some_property_name_2']
... 33 
$\endgroup$
0
$\begingroup$

Here's an example of adding Custom Properties from an Blender Add-on. It can be modified to remove the properties as well: https://github.com/MarioDelgadoSr/AddBlenderCustomPropertiesFromCSV

$\endgroup$
1
  • 5
    $\begingroup$ please always include the relevant code in your answer. Links are always bound to become invalid over time. $\endgroup$
    – aliasguru
    Jun 16, 2019 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .