Custom add-in: Store user preferences

Custom add-in: Store user preferences

DRoam
Mentor Mentor
517 Views
7 Replies
Message 1 of 8

Custom add-in: Store user preferences

DRoam
Mentor
Mentor

I can build a UI for specifying user preferences easily enough -- but what's the best way to store those so they persist from session to session? Can I have my add-in create an XML file for these? If so, where should said file be stored?

0 Likes
518 Views
7 Replies
Replies (7)
Message 2 of 8

HermJan.Otterman
Advisor
Advisor

If you build an addin, then you could read from and write to the windows registry...

https://docs.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/computer-resources/...

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 8

bradeneuropeArthur
Mentor
Mentor

use the setting of the add in

add a setting like Setting001 as boolean = true

 

then use this in your code

 

My.Settings.Setting001 = false ' or true

My.Settings.save

 

this will store the settings in the inventor XML file

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 4 of 8

DRoam
Mentor
Mentor

Hmm, that could work. Is that pretty safe to do as long as I'm staying inside my own custom key/folder? I would assume if I create my own key, say under "Computer\HKEY_CURRENT_USER\Software\<MyAddinName>", I don't need to worry about corrupting Windows or other applications. Is that correct?

0 Likes
Message 5 of 8

HermJan.Otterman
Advisor
Advisor

in visual studio you also have, under the application properties Settings.

here you also can store things

https://docs.microsoft.com/en-us/previous-versions/cftf714c(v=vs.100)

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 6 of 8

HermJan.Otterman
Advisor
Advisor

yes you can do that.

If you write an application for other people you could get some trouble with rights if they are limited

I used Hkey_currernt_User

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 7 of 8

bradeneuropeArthur
Mentor
Mentor

My mandatory or default settings are always loaded on loading the add in.

But before I do that I check if they exist and than only write them if they are not there.

So only when the user first starts the add in otherwise I don't write them. 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 8

DRoam
Mentor
Mentor

So there is a built-in settings mechanism in Visual Studio, that's really neat. Any advantages to using the registry over this?

 


@bradeneuropeArthur wrote:

My mandatory or default settings are always loaded on loading the add in.

But before I do that I check if they exist and than only write them if they are not there.

So only when the user first starts the add in otherwise I don't write them. 


Can you explain what you mean by this? How do you "check if they exist"? Exist where?

 

What do you mean you "don't write them" unless it's the first start? Aren't they already written in the app.config file at compile-time?

 

Thanks again for the help.

0 Likes