明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 533|回复: 16

工具选项板如何加载飞诗?

[复制链接]
发表于 2024-3-25 12:02 | 显示全部楼层 |阅读模式
本帖最后由 zilong136 于 2024-3-26 09:41 编辑

不想每次手动NETLOAD加载,想在工具选项板中搞个快捷方式,
如果想自动加载飞诗也行。

尝试以下代码,没有成功,希望高手指正。

  • (defun c:fs (/ str acad file)
  •   (setq str (getvar "acadver"))
  •   (setq acad (atof (substr str 1 (- (strlen str) 12))))
  •   (setq file "e:\\飞诗Lisp编辑器2016.6.1-1\\ ")
  •   (if
  •     (> 18.0 acad)
  •      (progn
  •        (command "netload" (strcat file "link35.dll"))
  •        (startapp (strcat file "lispedit.exe"))
  •      )
  •      (progn
  •        (if (/= (getvar "secureload") 0)
  •    (setvar "secureload" 0)
  •        )
  •        (command-s "netload" (strcat file "link40.dll"))
  •        (startapp (strcat file "lispedit.exe"))
  •        (setvar "secureload" 1)
  •      )
  •   )
  • )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2024-3-26 15:46 | 显示全部楼层
本帖最后由 jh1005 于 2024-3-26 17:49 编辑

;;要在CAD首次启动(也就是第一个文档)加载link40.dll或link35.dll才行。
;;把飞诗目录加入CAD搜索目录。
;;把该代码保存为lsp文件,把该文件加入启动组。

(defun c:fs ()   ;打开飞诗LispEdit编辑器
   (if (and (findfile "LispEdit.exe") (not (vl-position "lispedit" (mapcar 'vl-filename-base (fy_Progress)))))
      (startapp (findfile "LispEdit.exe"))
      (alert "没有找到飞诗LispEdit调试的LispEdit.exe文件,请加到CAD搜索目录。")
   )
   (princ)
)

(defun fy_Progress (/ apps item lst meth1 meth2 WMI)   ;读取系统进程
;;Writed By Patrick_35 @ TheSwamp.org
  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
        meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
        meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process"))
  (vlax-for item meth2
    (setq lst (append lst (list (vlax-get item 'CommandLine))))
  )
  (vlax-release-object WMI)
  (vlax-release-object meth1)
  (vlax-release-object meth2)
  (setq lst (vl-remove nil lst))
  (setq lst (mapcar '(lambda(x) (vl-string-translate  "/"  "\\"  (strcase x t))) lst))
   lst
)

(defun load_FSdll ()   ;;加载dll
        (if (and (findfile "Link35.dll") (findfile "Link40.dll"))
            (cond
                    ((>= (atof (getvar "ACADVER")) 20)
                          (setvar "cmdecho" 0)
                          (vl-cmdf "._netload" (findfile "Link40.dll"))
                      )
                    (t
                        (setvar "cmdecho" 0)
                        (vl-cmdf "._netload" (findfile "Link35.dll"))
                    )
                  )
             (princ "\n没有找到飞诗LispEdit调试的Link35.dll或Link40.dll,请加到CAD搜索目录。")
        )
     (princ)
)
(load_FSdll)
(princ "\n启动飞诗LispEdit编辑器,命令:fs")
(princ)





点评

这个可以。  发表于 2024-3-26 23:30
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2024-3-26 09:20 | 显示全部楼层

试过都没用,说注册表有问题:
命令: (LOAD "E:/飞诗Lisp编辑器2016.6.1-1/FS.lsp") C:FS
命令: fs 无法加载程序集。错误详细信息: System.ArgumentException: URL 上的无效目录。
   在 System.Security.Util.DirectoryString.CreateSeparatedString(String directory)
   在 System.Security.Util.URLString.ParseFileURL(String url)
   在 System.Security.Util.URLString.GetFileName()
   在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   在 System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   在 System.Reflection.Assembly.LoadFrom(String assemblyFile)
   在 Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)
   在 loadmgd()1
命令:
发表于 2024-3-26 08:33 来自手机 | 显示全部楼层
·
文件路径要用 \\
  1. (setq file "e:\\Lisp2016.6.1-1\\ ")
发表于 2024-3-26 10:23 | 显示全部楼层
zilong136 发表于 2024-3-26 09:20
试过都没用,说注册表有问题:
命令: (LOAD "E:/飞诗Lisp编辑器2016.6.1-1/FS.lsp") C:FS
命令: fs 无 ...

用易楼加载
 楼主| 发表于 2024-3-26 16:23 | 显示全部楼层
jh1005 发表于 2024-3-26 15:46
要在CAD首次启动时加载link40.dll或link35.dll才行

你代码是不是有问题?

点评

并且把飞诗目录加入CAD搜索目录  发表于 2024-3-26 17:54
已修改,再试试,用你的代码也行,但你必须在CAD第一个打开的文档加载dll  发表于 2024-3-26 17:52
 楼主| 发表于 2024-3-26 16:27 | 显示全部楼层

不行的,试过有问题才出来求助的
发表于 2024-3-26 20:22 | 显示全部楼层
加好搜索目录
(defun c:fss (/ file)
        (setq file "H:/cjr_box/飞诗Lisp编辑器2016.6.1/")
        (if (<= (atoi (substr (getvar "ACADVER") 1 2)) 18)
                (progn
                        (command "NETLOAD" (strcat file "link35.dll"))
                        (startapp (strcat file "lispedit.exe"))
                )
                (progn
                        (command-s "NETLOAD" (strcat file "link40.dll"))
                        (startapp (strcat file "lispedit.exe"))
                )
        )       
)
试试看
发表于 2024-3-26 21:44 | 显示全部楼层
zilong136 发表于 2024-3-26 16:27
不行的,试过有问题才出来求助的

易楼不能加载吗
 楼主| 发表于 2024-3-26 23:31 | 显示全部楼层

我没有成功,不知道还有哪里要注意的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-28 20:10 , Processed in 0.426087 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表