santh Posted July 8, 2009 Share Posted July 8, 2009 Hi I need to get the path of the active project in AutoCAD using VBA. I have found autocad API (ace_getactiveproject) to find the path, but i dont know how to use it in VBA.. Is their any other way to get the path?? Thanks in advance Quote Link to comment Share on other sites More sharing options...
SEANT Posted July 8, 2009 Share Posted July 8, 2009 The Developer Help (ActiveX and VBA Reference) has a good example. In the help file search for SetProjectFilePath Example. Quote Link to comment Share on other sites More sharing options...
santh Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks for ur input i have one more query. I have created a new project in Autocad electrical. Is it possible to retive the Activeproject name using VBA? thanks Quote Link to comment Share on other sites More sharing options...
SEANT Posted July 8, 2009 Share Posted July 8, 2009 Does this return the correct name? currProjName = ThisDrawing.GetVariable("PROJECTNAME") Quote Link to comment Share on other sites More sharing options...
santh Posted July 8, 2009 Author Share Posted July 8, 2009 When is use this currProjName = ThisDrawing.GetVariable("PROJECTNAME") statement it is returning empy string(currProjName ="" ) Instead of PROJECTNAME if I use "123"(My active project) am getting error "Error getting system variable" help me out pls thanks Quote Link to comment Share on other sites More sharing options...
SEANT Posted July 8, 2009 Share Posted July 8, 2009 It appears that the example I referred you to had errors. Try the revised example below, and see if this is helpful. Sub Example_SetProjectFilePath() ' This example finds the current project file information, changes ' that information, and finally resets the information back to the ' original values. Dim preferences As AcadPreferences Set preferences = ThisDrawing.Application.preferences ' Get the current project file information Dim currProjPath As String Dim currProjName As Variant currProjName = ThisDrawing.GetVariable("PROJECTNAME") If currProjName <> "" Then currProjPath = preferences.Files.GetProjectFilePath(currProjName) End If If currProjPath = "" Then MsgBox "There is no current project file or path. ", , "SetProjectFilePath Example" Else MsgBox "The current project file path is: " & currProjPath, , "SetProjectFilePath Example" ' Set new project file information. ' Change drive/path as necessary to match your system Dim newProjPath As String newProjPath = "C:/AutoCAD/" preferences.Files.SetProjectFilePath currProjName, newProjPath MsgBox "The new project file path is: " & newProjPath, , "GetProjectFilePath Example" ' Reset the project file information preferences.Files.SetProjectFilePath currProjName, currProjPath MsgBox "The project file path has been reset to: " & currProjPath, , "GetProjectFilePath Example" End If End Sub Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.