Attributes automatically placed on new person

I have a number of Attributes that I keep on the Collection Clipboard to place in the Attributes of an individual it would be really helpful to have a list of attributes which could be place into a Person at the time of creation of that individual.
Or on the Collection Clipboard you could select multiple items to drag & drop

You could create SuperTool script to do that.

Just curiosity, what attributes do you attach on a newly added person?

1 Like

Suppose that is as good a reason as I need to learn about SuperTool

1 Like

Currently they are all related to DNA information but I suspect others
might rear there head

Bruce Jackson ( @ebj075 ) wrote a SuperTool script (posted to GitHub) that reads from a CSV and attaches 2 Attributes (Ancestry ID and URL) to a series of Person IDs. It is more complex than your task but you can use it as an example.

Here’s the thread: Using Supertool to import Attributes and URLs - An example

I recommend that you paste his Script into a Note of SuperTool Script type. The Note Editor gives a larger editing window so you need to scroll less than in the SuperTool Editor. SuperTool (v1.4.0 and later) has a File menu with a “Load from Note” option… but you have to have the correct Category active to show the Note in SuperTool’s selector dialog.

A Supertool script can add attributes to a person but not automatically for each new person.

However, a trick like this should work. Write code to augment the Person.init method with code to add the attributes. Something like

Person.orig_init = Person.__init__

def new_init(self, *args, **kwargs):
    # Call the original __init__
    Person.orig_init(self, *args, **kwargs)
    # Sample code to add an attribute:
    a = Attribute()
Person.__init__ = new_init

Each new person created after running this code would contain the attribute “My-attr” with value “123”.

Of course the code to add the attributes would be more complex if the attributes need to be retrieved from the Clipboard.

The code above could be run in a Supertool script - but then it would need to be run manually each time Gramps is started. An alternative would be to put the code in a “GENERAL” type of an addon that uses the load_on_reg feature. Then the code would run automatically at startup.


Maybe it could use a “dummy” object as reference template and clone (or alternatively, ‘share’) secondary objects in the INIT ?