newer 发表于 2021-1-26 16:23:56

设置项目文件搜索路径

问题:

Setting The Project File Search Path


解答:

If you use the Drawing projects feature of AutoCAD regularly, you might wonder how to get/set the project file search path programmatically?

To get the project file path name, use the GetProjectFilePath method of AcadPreferencesFiles object accessible using the ActiveX API. You can also set the project file path name using SetProjectFilePath method of AcadPreferencesFiles object. And the current project name is stored in the system variable "PROJECTNAME".

There are however no ActiveX methods available to obtain the list of project names that you can access through Options dialog in the UI. One work around would be to directly read the information from the registry. The project names will be available under the following key.

HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\RXX.X\ACAD-XXXX:XXX\Profiles\<<Unnamed Profile>>\Project Settings\

The following sample VBA code gets the path information for the Project called "TestProject". Remember to add a project by name TestProject before testing this sample.

Sub f_test()
Dim po_pref As AcadPreferences
Set po_pref = ThisDrawing.Application.Preferences

MsgBox po_pref.Files.GetProjectFilePath("TestProject")
Call po_pref.Files.SetProjectFilePath("TestProject",
                                    "c:\my documents")
End Sub


页: [1]
查看完整版本: 设置项目文件搜索路径