* Creating a fact set from within a plugin

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
ColeValleyGirl
Megastar
Posts: 5502
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Creating a fact set from within a plugin

Post by ColeValleyGirl »

Does anyone have any ideas about how to create a fact set from within a plugin **and** have it immediately available?

I can download(say) x.fhf from the net, save it to my plugin data folder and then open it and the fact set is installed BUT it isn't available until FH is closed and reopened (the same behaviour as when you install a fact set by opening the fhf file manually).

FH only seems to recognise an imported fact set immediately if it's imported via the File >..>Import>Fact Set menu option, and that isn't accessible from within a plugin.

And although you can create a Tag in the FH API, you can't associate sentences, default notes etc. or define which fact set it belongs to.

Any ideas?
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Creating a fact set from within a plugin

Post by tatewise »

Sorry, my first reaction is I don't think it is possible.

I would like to know how you have even created a Tag via the FH API.

fhCreateItem(...) does not work unless the Tag already exists, either in a Fact Set, or somewhere else in the GEDCOM file.

BTW:
I face a similar challenge with my Change Any Fact Tag Plugin.
It can only change an existing Tag to a Fact Tag that is predefined.
The user cannot choose a new target Fact Tag within the Plugin.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
ColeValleyGirl
Megastar
Posts: 5502
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Creating a fact set from within a plugin

Post by ColeValleyGirl »

fhGetFactTag will test for the existence of a fact tag and optionally create it if it doesn't exist -- but it only creates the bare tag and you can't e.g. add custom sentences, or define what fields are required.

I suspect I will just have to tell the user to restart the FH to complete the Fact Set installation.
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Creating a fact set from within a plugin

Post by tatewise »

Ah yes, I had forgotten about that effect of the fhGetFactTag(...) function. :oops:
That is equivalent to the case where the Fact Tag exists somewhere in the GEDCOM file but without a Fact Set definition.
Telling the user to restart FH is probably the only workaround currently.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
ColeValleyGirl
Megastar
Posts: 5502
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Creating a fact set from within a plugin

Post by ColeValleyGirl »

And while we're on the subject of Plugins and fact definitions...

If you create a fact within a plugin, it doesn't seem to autocreate a note.
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Creating a fact set from within a plugin

Post by tatewise »

Yes, I have repeated that problem scenario.
It is a bug that should to be reported to Calico Pie.

A workaround would be for the Plugin to open and read the Fact Definition (.fhf) file(s) to find the Fact and its Auto Note entry, then copy the text to the NOTE2 field. Quite an awkward process!
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
ColeValleyGirl
Megastar
Posts: 5502
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Creating a fact set from within a plugin

Post by ColeValleyGirl »

An awkward process, and at the mercy of changes in the fhf file format...

I'll report the bug.
Post Reply