I need a little help with my code.
I know how to add a new entry or get the paths available for an entry using GetProjectFilePath() and SetProjectFilePath(). SetProjectFilePath() overwrites the paths if the entry is already on the list. I know how to append new paths to an entry if the entry is already on the list but I have not been able to find a way to check if an entry is already on the list. What I need if the function to return true if the my new entry is on the list and false if is not. I've tried different ways that this is the simplest
p_Name = the entry that I'm searching for.
Privat Function IsValid(p_Name AsString) AsBoolean
Dim acPref AsAcadPreferences = Application.Preferences
If Not acPref.Files.GetProjectFilePath(p_Name) = NothingThen 'this is where I get the error
ReturnTrue
EndIf
ReturnFalse
EndFunction
If there is a better way by all means point it out.
If anyone is insterested in the solution the function below took take of my problem. There is no way to loop through the projectnames on your profile other than reading the entries on the registry.
Private Function IsValid(p_Name AsString) AsBoolean
Dim acadpref As AcadPreferences = Application.Preferences
Dim profileName As String = acadpref.Profiles.ActiveProfile.ToString
Dim path As String = "Software\Autodesk\AutoCAD\R19.0\ACAD-B016:409\Profiles\" & profileName & "\Project Settings"
Dim rk AsRegistryKey = Registry.CurrentUser.OpenSubKey(path)
ForEach item In rk.GetSubKeyNames()
If item.ToString.ToUpper = p_Name.ToUpper Then
ReturnTrue
EndIf
Next
ReturnFalse
EndFunction