CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

RenameProfile 方法 (ActiveX)

2024-5-18 18:20| 发布者: admin| 查看: 72| 评论: 0|原作者: admin|来自: AutoCAD

RenameProfile 方法 (ActiveX)

重命名指定的配置文件。

支持的平台:仅限 Windows

签名

VBA:

object.RenameProfile origProfileName, newProfileName
对象

类型:PreferencesProfiles

此方法应用到的对象。

origProfileName

访问:仅输入

类型:字符串

当前配置文件名称。

newProfileName (新配置文件名称)

访问:仅输入

类型:字符串

配置文件的新名称。

返回值 (RetVal)

无返回值。

言论

没有其他评论。

例子

VBA:

Sub Example_RenameProfile()
    ' This example renames an existing profile.
    ' You can see the renamed profile under Options/Profiles
    '
    ' *Note: This example relies on the default profile "<<Unnamed Profile>>".
    ' If this profile has already been renamed or removed, be sure to change the
    ' name of the SourceProfile to one that currently exists.
    
    Dim ACADPref As AcadPreferencesProfiles
    Dim SourceProfile As String, DestinationProfile As String
    
    ' Get the profiles preferences object
    Set ACADPref = ThisDrawing.Application.preferences.Profiles
    
    ' Rename the default profile
    On Error GoTo ERRORTRAP
    
    SourceProfile = "<<Unnamed Profile>>"
    DestinationProfile = "NEW_PROFILE_NAME"
        
    ACADPref.RenameProfile SourceProfile, DestinationProfile

    MsgBox "We have just renamed the profile " & SourceProfile & " to " & DestinationProfile
    
    Exit Sub
    
ERRORTRAP:
    If Err.Description <> "" Then
        MsgBox "The default profile '" & SourceProfile & "' cannot be found, please use a different source profile."
    End If

End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_RenameProfile()
    ;; This example renames an existing profile.
    ;; You can see the renamed profile under Options/Profiles
    ;;
    ;; *Note: This example relies on the default profile "<<Unnamed Profile>>".
    ;; If this profile has already been renamed or removed, be sure to change the
    ;; name of the SourceProfile to one that currently exists.
    (setq acadObj (vlax-get-acad-object))
    (setq preferences (vla-get-Preferences acadObj))

    ;; Rename the default profile
    (setq sourceProfile "<<Unnamed Profile>>"
          destinationProfile "NEW_PROFILE_NAME")
  
    (setq err (vl-catch-all-apply 'vla-RenameProfile (list (vla-get-Profiles preferences) sourceProfile destinationProfile)))

    (if (= (type err) 'VL-CATCH-ALL-APPLY-ERROR)
        (alert (strcat "The default profile '" SourceProfile "' cannot be found, please use a different source profile."))
        (alert (strcat "We have just renamed the profile " SourceProfile " to " DestinationProfile))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-1-19 06:44

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部