Save input data

Save input data

RECArchi
Collaborator Collaborator
1,626 Views
10 Replies
Message 1 of 11

Save input data

RECArchi
Collaborator
Collaborator

Is it possible to save input data (text, boolean, etc) that user entered using the plugin ? If yes, what would be the best file format to use, to keep this information? I would like users to be able to "load" this data later (for example, if they close the Revit Project and re-open it).

Thank you in advance.

Sincerely.

0 Likes
1,627 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

You can use ExtensibleStorage

0 Likes
Message 3 of 11

vkelani
Contributor
Contributor

You can use the application settings Default values, and update the default values every time user inputs the value and save it. This way, the texts, numbers etc are available the next time the project/program is opened. This is more efficient than using Extensible storage. 

 

Cheers!

Vish K.

0 Likes
Message 4 of 11

RECArchi
Collaborator
Collaborator

Are you refering to the 2nd option in this post ?

https://thebuildingcoder.typepad.com/blog/2014/03/storing-revit-add-in-settings.html

 

I want to have different settings for different projects. Thus, I think I'm gonna use ExtensibleStorage.

 

Sincerely.

0 Likes
Message 5 of 11

vkelani
Contributor
Contributor

@RECArchi  

Yes, that’s accurate. 
I am sure you know why people prefer app settings over extensible storage but if your requirements needs to have extensible storage then go ahead. 
I recently did research to implement the same for myself, and I’d still go with app settings over extensible storage for the user preferences because of obvious reasons. 
let me know if you need any further help on this.

 

cheers!

Vish K.

0 Likes
Message 6 of 11

RECArchi
Collaborator
Collaborator

Thank you for your reply.

 

Indeed, I use ExtensibleStorage and it seems to work as I want

 

Other question : I want to be able to retrieve this data from my .cs file and reinject it to the default values that I use for fields (textboxes, comboboxes, etc.) of the WPF window. How can I do this ?

 

For the moment, my .xaml.cs file only contains default values I put manually. Example :

 

public static double HF = 6 ;
public static double HF_sel { get { return HF; } set { HF = value; } }

 

Thank you in advance.

 

Sincerely.

0 Likes
Message 7 of 11

vkelani
Contributor
Contributor

Hi,

 

if by “this data” you mean the data you saved in element using Extensible storage, and assuming by saying “from .cs file” you mean in your code because the data stored using extensible storage is stored in revit element and not your .cs file. Now, in your code, You can get it by retrieving that element in which you stored the data and using get entity the data can be retrieved from that element. 

hope this helps!

cheers,

Vish K.

0 Likes
Message 8 of 11

RECArchi
Collaborator
Collaborator

Yes, I manage easily to retrieve this data stored in element using ExtensibleStorage in my code.

What I want to do is to retrieve this data in my view model (the code that is used for my WPF window). I want to display this data in textblocs of my WPF window, for instance.

I've read that Revit classes should not be used within the view model:

https://mathcadbimthingy.wordpress.com/2017/01/25/view-viewmodel-ing-for-your-wpf-windows-revit-api-...

Is that right ? If yes, what should I do ?

(Sorry I'm not an IT, I have basics knowledge in programming…)

Sincerely.

0 Likes
Message 9 of 11

vkelani
Contributor
Contributor

Once you retrieved your data, you can store wpf textbox or any item value by first setting its modifier settings from private to public or whatever you want to so you can access that settings in your code to set the value.

set the values before form.showdialog and make sure to refresh the form. 

Cheers!

Vish. k.

0 Likes
Message 10 of 11

RECArchi
Collaborator
Collaborator

Okay ! Indeed, my mistake was to initialize values manually. I initialized textblocs values from my code, and now it works !

Thank you for your help.

Sincerely.

0 Likes
Message 11 of 11

RECArchi
Collaborator
Collaborator

From the new Revit 2021 API, I have deprecated data : DisplayUnitType, UnitSymbolType and UnitType. I replaced them by UnitTypeId, SymbolTypeId and SpecTypeId.

However, I can't store data like checkboxes (booleans) or numbers from ratios (no units) because the old DisplayUnitType "UT_Undefined" no longer exist in ForgeTypeId.

How can I solve this problem ?

Thank you in advance.

Sincerely.

0 Likes