明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: aicr317

[原创]看来这个问题是没人能解决了!放弃!!!

  [复制链接]
 楼主| 发表于 2008-2-18 18:17:00 | 显示全部楼层

 楼主| 发表于 2008-2-18 23:03:00 | 显示全部楼层

我继续顶起来

发表于 2008-2-19 00:17:00 | 显示全部楼层

1.把scei_placemenu中的(if (> n 3)(setq n (- n 2))(setq n 3))删掉或屏蔽掉就可以在最后插入菜单了。把(setq n (- n 2))改成)(setq n (- n 1))可以在帮助前面添加菜单,如此类推       

发表于 2008-2-19 00:21:00 | 显示全部楼层
2.是因为你的VBA宏已经加载。我对VBA不是很熟悉,不知道它加载后会不会在atoms-family添加符号,如果有的话,可以在运行命令前判断是否已经加载,没有加载的时候再运行
发表于 2008-2-19 00:25:00 | 显示全部楼层
或者不妨考虑用vl-vbaload,放弃command
 楼主| 发表于 2008-2-19 03:05:00 | 显示全部楼层

感谢楼上的朋友,解决1个菜单条位置的问题,还有最关键的问题添加支持路径的问题期待回复!谢谢!

发表于 2008-2-19 13:04:00 | 显示全部楼层

我觉得你添加路径的程序麻烦了
1.不需要过滤重复路径,CAD会自动给你过滤
2.不需要转换成list
  在前面添加(setenv "ACAD" (strcat athToAdd ";" (getenv "ACAD")))
  在后面添加(setenv "ACAD" (strcat (getenv "ACAD") ";" PathToAdd))

 楼主| 发表于 2008-2-19 15:28:00 | 显示全部楼层

我刚学LSP,问题会比较菜,谅解,请问按你上面说的,分别添加在哪里啊,谢谢!(前面和后面分别是哪里啊?)

发表于 2008-2-19 17:04:00 | 显示全部楼层

不知道你是怎么使用AddSupportPath这个函数的,可否发上来看看。以下是我做的一些简化


;;; 添加支持文件搜索路径
;;; ---------------------------------------------------------------------------------
;;; note:  第二个参数如果为真, 插最前,否则插最后
;;;       
(defun AddSupportPath (PathToAdd isFirst)
  (if isFirst
    (setenv "ACAD" (strcat PathToAdd ";" (getenv "ACAD")))
    (setenv "ACAD" (strcat (getenv "ACAD") ";" PathToAdd))
  )
)

 楼主| 发表于 2008-2-19 17:57:00 | 显示全部楼层

以下是我的代码:

;;; 判断是否加载本文件
(if (car (atoms-family 1 '("vl-load-com")))
  (vl-load-com)
  ;;else
  (progn
    (Alert
      "这个程序集是为AutoCAD 2000以及更高的版本设计的,许多程序有可能在没有Visual Lisp for R14支持的AutoCAD R14上不能正确地运行。"
    )
    (exit) ; 版本不符,退出加载。
  )
)

;;; 以下定义文件中用到的函数
;;;----------------------------------------------------------------------------------

;;; 取得本程序的路径
;;; ---------------------------------------------------------------------------------
(defun GetMyApplicationPath (AppID)
  (vl-registry-read
    (strcat
      "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
      AppID
      "_is1"
    )
    "Inno Setup: App Path"
  )
)

(defun GetsceiPath ()
  (GetMyApplicationPath "1")
)

;;; 解析字符串为表(函数来自明经通道转载)
;;; ---------------------------------------------------------------------------------
(defun strParse    (Str Delimiter / SearchStr StringLen return n char)
  (setq SearchStr Str)
  (setq StringLen (strlen SearchStr))
  (setq return '())
  (while (> StringLen 0)
    (setq n 1)
    (setq char (substr SearchStr 1 1))
    (while (and (/= char Delimiter) (/= char ""))
      (setq n (1+ n))
      (setq char (substr SearchStr n 1))
    ) ;_ end of while
    (setq return (cons (substr SearchStr 1 (1- n)) return))
    (setq SearchStr (substr SearchStr (1+ n) StringLen))
    (setq StringLen (strlen SearchStr))
  ) ;_ end of while
  (reverse return)
) ;_ end of defun

;;; 反解析表为字符串(函数来自明经通道转载)
;;; ---------------------------------------------------------------------------------
(defun StrUnParse (Lst Delimiter / return)
  (setq return "")
  (foreach str Lst
    (setq return (strcat return Delimiter str))
  ) ;_ end of foreach
  (substr return 2)
) ;_ end of defun

;;; 移除支持文件搜索路径
;;; ---------------------------------------------------------------------------------
(defun RemoveSupportPath (PathToRemove / supportlist)
  (setq supportlist (strparse (getenv "ACAD") ";"))
  (setq supportlist (vl-remove "" supportlist))
  (setq    supportlist
     (vl-remove-if
       '(lambda (x) (= (strcase x) (strcase PathToRemove)))
       supportlist
     )
  )
  (setenv "ACAD" (strUnParse supportlist ";"))
)

;;; 添加支持文件搜索路径
;;; ---------------------------------------------------------------------------------
;;; note:  第二个参数如果为真, 插最前,否则插最后
;;;       
(defun AddSupportPath (PathToAdd isFirst)
  (if isFirst
    (setenv "ACAD" (strcat PathToAdd ";" (getenv "ACAD")))
    (setenv "ACAD" (strcat (getenv "ACAD") ";" PathToAdd))
  )
)

;;; 根据不同的AutoCAD版本加载不同的菜单文件:
(defun Load_sceiMenu (/ acadver)
  (setq acadver (atof (getvar "acadver")))
  (cond
    ((and (>= acadver 15.0) (< acadver 16.0))
     (command "_menuload" "scei.mnu")
    )
    ((and (>= acadver 16.0) (<= acadver 16.1))
     (command "_menuload" "all.mns")
    )
    ((>= acadver 16.2) (command "_menuload" "scei2006.mnu"))
  )
)

;;; The following code "placemenu" written by LUCAS
;;; 插入菜单条 Placemenu由LUCAS编写
;;; ---------------------------------------------------------------------------------
(defun scei_PlaceMenu    (/ n)
  (if (menugroup "scei")
    (progn
      (setq n 1)
      (while (< n 24)
    (if (menucmd (strcat "P" (itoa n) ".1=?"))
      (setq n (+ n 1))
      (progn
        (if    (> n 3)
          (setq n (- n 2))
          (setq n 3)
        )                ;if
        (menucmd (strcat "p" (itoa n) "=+scei.pop3"))
        (menucmd (strcat "p" (itoa n) "=+scei.pop2"))
        (menucmd (strcat "p" (itoa n) "=+scei.pop1"))
        (setq n 25)
      )                ;progn
    )                ;if
      )                    ;while
    )                    ;progn
  )                    ;if
  (princ)
)

;;; 初始化主函数
;;; ---------------------------------------------------
(defun Init_scei ()
  ;; 添加支持路径
  (AddSupportPath (GetsceiPath) nil)
  (AddSupportPath (strcat (GetsceiPath) "\\1") nil)
  (AddSupportPath (strcat (GetsceiPath) "\\2") nil)
  (AddSupportPath (strcat (GetsceiPath) "\\3") nil)
  (AddSupportPath (strcat (GetsceiPath) "\\4") nil)


  ;; 如果菜单组还没有被加载,则加载之
  (if (not (menugroup "scei"))
    (Load_sceiMenu)
  )

  ;; 安排菜单条的位置
  (scei_PlaceMenu)

  (princ)
)
;;; 以上函数部分定义完毕

;;; -----------------------------------------------------
;;; 主程序:
;;; -----------------------------------------------------
(princ "\n加载scei工具集……")

(setq scei_cmdecho_save (getvar "cmdecho"))
(setvar "cmdecho" 0)

;;; 执行初始化
(Init_scei)

(setvar "cmdecho" scei_cmdecho_save)
(setq scei_cmdecho_save nil)

(princ "\nscei工具集加载完毕。版本 2005.4")
(princ)

;; 加载主程序
;; 为节省内存,这里也可以以autoload函数形式定义
;; 有几条写几条
(load "scei.lsp")
(arxload "scei.arx")
(princ)

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-19 18:54 , Processed in 0.162131 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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