找到完美解决方案与大家分享
(defun Example_SupportPath ()
;;;这个范例返回
;;;SupportPath的当前设定值,接着改变它的值,最后恢复初始值
(VL-LOAD-COM)
(setq AcadObject (vlax-get-acad-object)
AcadDocument (vla-get-ActiveDocument AcadObject)
mSpace (vla-get-ModelSpace AcadDocument)
)
(setq preferenceSel (vla-get-Preferences AcadObject))
(setq fileSel (vla-get-Files preferenceSel))
;;;取出当前的SupportPath值
(setq currSupportPath (vla-get-SupportPath fileSel))
(princ "SupportPath的值当前设定为: ")
(princ currSupportPath)
(princ " SupportPath范例\n")
(PROMPT "<Enter>进行:")
(VL-CMDF pause)
;;;改变SupportPath的值
(vla-put-SupportPath fileSel "TestSupportPath")
(setq newSupportPath (vla-get-SupportPath fileSel))
(princ "SupportPath的新值设定为: ")
(princ newSupportPath)
(princ " SupportPath范例\n")
(PROMPT "<Enter>进行:")
(VL-CMDF pause)
;;;将 SupportPath 重设为原来的值
(vla-put-SupportPath fileSel currSupportPath)
(vla-Regen AcadDocument acAllViewports)
(princ "SupportPath的值已经重设为: ")
(princ currSupportPath)
(princ " SupportPath范例\n")
(princ)
) |