.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to check if a projectname is in my profile

1 REPLY 1
Reply
Message 1 of 2
Anonymous
233 Views, 1 Reply

How to check if a projectname is in my profile

ProjectFiles.pngI 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.

 

 

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost