CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SetProjectFilePath Method (ActiveX)

2023-1-4 01:38| 发布者: admin| 查看: 352| 评论: 0|来自: AutoCAD

摘要: 设置 AutoCAD 在其中查找外部参照文件的目录。

设置 AutoCAD 在其中查找外部参照文件的目录。

支持的平台:仅窗口

签名

工 务 局:

object.SetProjectFilePath ProjectName, ProjectFilePath
对象

类型:首选项文件

此方法适用的对象。

项目名称

访问:仅输入

类型:字符串

项目的名称。此名称也由 PROJECTNAME 系统变量控制。

项目文件路径

访问:仅输入

类型:字符串

AutoCAD 在其中查找外部参照文件的目录。

返回值(RetVal)

无返回值。

言论

没有额外的评论。

例子

工 务 局:

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.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.SetProjectFilePath currProjName, newProjPath
        MsgBox "The new project file path is: " & newProjPath, , "GetProjectFilePath Example"
        
        ' Reset the project file information
        preferences.SetProjectFilePath currProjName, currProjPath
        MsgBox "The project file path has been reset to: " & currProjPath, , "GetProjectFilePath Example"
    End If
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetProjectFilePath()
    ;; This example finds the current project file information, changes
    ;; that information, and finally resets the information back to the
    ;; original values.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq preferences (vla-get-Preferences acadObj))

    ;; Get the current project file information
    (setq currProjName (vlax-variant-value (vla-GetVariable doc "PROJECTNAME")))
    (if (/= currProjName "")
        (setq currProjPath (vla-GetProjectFilePath (vla-get-Files preferences) currProjName))
        (setq currProjPath "")
    )
    (if (= currProjPath "")
        (alert "There is no current project file or path. ")
        (progn
	           (alert (strcat "The current project file path is: " currProjPath))

            ;; Set new project file information.
            ;; Change drive/path as necessary to match your system
            (setq newProjPath "C:/AutoCAD/")

            (vla-SetProjectFilePath (vla-get-Files preferences) currProjName newProjPath)
            (alert (strcat "The new project file path is: " newProjPath))

            ;; Reset the project file information
            (vla-SetProjectFilePath (vla-get-Files preferences) currProjName currProjPath)
            (alert (strcat "The project file path has been reset to: " currProjPath))
        )
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 16:53

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部