How to store plugin Preferences

How to store plugin Preferences

Anonymous
Not applicable
1,573 Views
4 Replies
Message 1 of 5

How to store plugin Preferences

Anonymous
Not applicable

Hi

I am trying to find a way to store user preferences for my plugin.

These preferences are file paths, import options etc. so that the next time the user runs the plugin

all the choices he made the fist time he used the plugin stay the same.

Is there an API functionality which helps in this? Are there any guidlines how to do that? any user experience in the Forum about this issue.

 

Thanks in advance

Dimi

0 Likes
Accepted solutions (1)
1,574 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution
If you are using Visual Studio C#, there is feature made exactly for this. Have a look at "Using settings in C#" here: http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx This is what I do. Some people who want more control will develop their own system, but I suggest starting here. It is really easy and effective.
0 Likes
Message 3 of 5

ollikat
Collaborator
Collaborator
Hi

Another approach could be so called Extensible Storage mechanism in Revit API. That would allow you to save project specific settings. I mean a scenario where user wants to have different settings in different project. You can read more about it from BuildingCoder block

http://thebuildingcoder.typepad.com/blog/2011/04/extensible-storage.html

But if you are just trying to store information, that doesn't have direct relationship to Revit project, then it might be better to use mechanism that peterjegan suggested.

Message 4 of 5

Anonymous
Not applicable

Thanks for the nice links,

the setting are not project specific so I will give the using settings of @peterjegan a try.

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi

the C#  Visual Studio User Settings suggested by @peterjegan worked fine.

Neverheless in my case its was even easier sinc I wanted user setting for Windows Forms entries. There is a way to associate user settings with a Windows Form component inside the Form Designer. This means even less code for reading/writing.

http://msdn.microsoft.com/en-us/library/wabtadw6%28v=vs.110%29.aspx

 

The only CAVEAT I found is that you have to call save before closing the Form otherwise the settings get lost.

Properties.Settings.Default.Save();

0 Likes