The Courage Dog 发表于 2022-7-6 14:19:05

要加载的配置文件(.ARG)

你好。。。我在不同的项目中工作,使用不同的cad标准和库块。为了使这些事情有条理,我创建了项目特定的配置文件(.ARG文件),可以从“工具”然后“选项”然后“配置文件”导入。令人讨厌的是,每次我处理特定项目时,我都必须再次导入正确的配置文件(.ARG)文件,以获得必要的设置(即支持文件路径、菜单、CUI、PC3路径、绘图样式、模板等)
 
我的问题是。。。有没有像LISP例程这样的捷径可以直接加载,以便自动导入所需的概要文件(.arg)?而不是一次又一次地去“工具”“选项”“配置文件”。
 
非常感谢您的回复。。。。
 
谢谢
勇气犬

NBC 发表于 2022-7-6 14:25:04

我不太清楚,但我猜这会与之相关-VLA-PUT-ACTIVEPROFILE

Lee Mac 发表于 2022-7-6 14:29:25

不确定这是否可行?
 
{未测试}
 

(defun c:PutProf ()
(vl-load-com)
(if (findfile "profile.arg")
   (vla-put-ActiveProfile
   (vla-get-Profiles
       (vla-get-Preferences
         (vla-get-ActiveDocument
         (vlax-get-acad-object)))) "profile")
   (princ "\n<< Profile.arg could not be found >>"))
(princ))

 
(将“profile”的所有实例更改为正确的名称)

The Courage Dog 发表于 2022-7-6 14:34:28

李先生,
我试过你的代码,但没有;t锻炼了。有谁有这个想法?
 
谢谢所有回复我的人。

Commandobill 发表于 2022-7-6 14:38:40

看见http://www.cadtutor.net/forum/showthread.php?t=11156

Lee Mac 发表于 2022-7-6 14:41:05

 
ASMI在该帖子中发布的第一个代码的工作方式与我的类似,所以我很想知道为什么我的失败。。。

The Courage Dog 发表于 2022-7-6 14:45:37

我有你的密码commandobill。。。如果我的配置文件(.arg)位于不同的路径中,我该如何将其更新到您的代码中?还有一件事,我必须把所有的“ProfileName”改成我的profile name吗?对不起,我编程不太好。

Commandobill 发表于 2022-7-6 14:49:38

 
首先,您要检查文件是否存在,但绝不要将其加载到Autocad中。然后,您的层次结构有点不适合获取配置文件,因为您通过获取activedocument而深入了一点。不过,对于未经测试的人来说并不太寒酸
 
 
在这里,我更改了ASMI的代码,以便它检查是否已在autocad中加载,如果未加载,它将搜索您指定的文件位置,以查看文件是否存在,如果存在,它将加载它。你所要做的就是将c:\\更改为保存个人资料的任何驱动器。
 
(defun c:LoadProfile( / profCol profLst ProfileName)
(vl-load-com)
(setq ProfileName (getstring "\nEnter the name of the profile you wish to load: "))
(setq profCol ; get profiles collection
    (vla-get-Profiles
      (vla-get-Preferences
      (vlax-get-acad-object))))
(vla-GetAllProfileNames profCol 'profLst)

(if (and (not (member ProfileName (vlax-safearray->list profLst))) ; if profile exists
      (findfile (setq Profileloc (strcat "c:\\" Profilename ".arg"))))
   (progn
   (vla-importprofile profcol Profilename Profileloc :vlax-false)
   (vla-GetAllProfileNames profCol 'profLst)))
(if (member ProfileName (vlax-safearray->list proflst))
   (progn
   (if
   (vl-catch-all-error-p
   (vl-catch-all-apply
       'vla-put-ActiveProfile
       (list profCol ProfileName))) ; profile loading and error catching
   (princ
   (strcat "\nError loading profile <"
         ProfileName ">.")); error message
   (princ
   (strcat "\nProfile <" ProfileName
         "> successfully loaded. ")); success message
   ); end if
   ); end progn
   (princ
   (strcat "\nProfile <" ProfileName "> not found. ")); not found message
   ); end if
(princ)
); end of LoadProfile

The Courage Dog 发表于 2022-7-6 14:52:08

我遵循了您的指示,以下是我的autocad屏幕上显示的内容:
 
命令:appload
加载配置文件。LSP已成功加载。
 
命令:;错误:语法错误

Lee Mac 发表于 2022-7-6 14:57:02

你确定你复制了整个代码吗?
 
对我来说似乎负荷正常
页: [1] 2
查看完整版本: 要加载的配置文件(.ARG)