2010年08月 存档

spline转pline的超精简代码

2010年08月31日,星期二

说明:
这段程序是偶然发现的思路,长仅23行,虽不完美但很有趣。
优点:代码简洁,速度快,拟和度良好。
缺点:不能处理曲线自交情形,这个改起来很麻烦。不能处理闭合,这个很容易修改。有的时候不管用,这个好像没办法。
声明一下,本程序并非实用程序,仅供编程思路上的参考。

求助尺寸标注程序

2010年08月31日,星期二

直接在cad中标注尺寸,尺寸线长短不一,捕着对齐不方便.望朋友相赠.

请问这个文件如何打开?

2010年08月31日,星期二

我在图纸中心下载了一个lisp学习的资料,后缀名是.005,请问怎样打开?
以下是链接:
http://www.xdcad.net/drawcenter/lis…page=1&setid=49

找多义线形心

2010年08月31日,星期二

我有一个找多义线程序,但有时不能用,要找多义线炸开再重新连接才可以,不知道为什么,请各位大侠指教。
(defun c:zxx (/ se rg f xxx xxy xxx1 xxy1 xxx2 xxy2 cep)
(setar “CMDECHO” 0)
(setar “FILEDIA” 0)
(setar “LUPREC” 8)
(setq se (entsel “n 请选取欲求形心的多义线:”))
(command “copy” se “” “0,0″ “0,0″)
(command “region” se “”)
(setq rg (entget (entlast)))
(command “massprop” “l” “” “y” “f:/ZZX.mpr”)
(command “erase” “l” “”)
(setq f (open “f:/ZZX.mpr” “r”))
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(setq xxx (read-line f))
(setq xxy (read-line f))
(close f)
(setq xxx1 (substr xxx 25 20))
(setq xxy1 (substr xxy 25 20))
(setq xxx2 (atof xxx1))
(setq xxy2 (atof xxy1))
(setq cep (list xxx2 xxy2 0))
(entmake (list (cons 0 “point”) (cons 8 “temp”) (cons 10 cep)))
(setar “FILEDIA” 1)
(setar “LUPREC” 0)
(l-file-delete “f:/ZZX.mpr”)
)

我为什么不能自动加入菜单?谢谢。另外为什么无法回帖?

2010年08月31日,星期二

为什么不能回帖了?不知道违反了哪个发贴规则,请明示。
按照xyp1964兄的方法,我昨天试了一晚上始终不得要领。还望各位帮一把。
这次我修改后,不知为什么菜单总加不上,支持路径倒加上了进入后,在加载应用程序内手工加载一遍就ok了。这次不知问题出在哪里。
;;; 判断是否加载本文件
(if (car (atoms-family 1 ‘(“l-load-com”)))
(l-load-com)
(progn
(Alert
“阿炳设计助手提示您:非常抱歉,这个程序集是为AutoCAD 2000以及更高的版本设计的,许多程序有可能在AutoCAD R14上不能正确地运行,建议您升级至2000以上版本。”
)
(exit); 版本不符,退出加载。
)
)
;; 首先定义初始化函数
(defun InitarbingApplication (/
GetMyApplicationPath
GetarbingPath
strParse
StrUnParse
arbing_AddSupportPath
Load_arbingMenu
arbing_placemenu
arbing_cmdecho_sae
)
;;; 取得本程序的路径.
;;; 文件路径从注册表中读取,这些信息由安装程序负责写入注册表
;;; ———————————————————————————
(defun GetMyApplicationPath (AppID)
(l-registry-read
(strcat
“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentersion\Uninstall\”
AppID
“_is1″
)
“Inno Setup: App Path”
)
)
;; 这里取得安装后,安装的文件夹的绝对路径
;; 注意:这里的AppID为”阿炳设计助手”, 稍后的安装程序制作向导设置中必须与这里保持一致
(defun GetarbingPath ()
(GetMyApplicationPath “阿炳设计助手”)
)
;;; 解析字符串为表(函数来自明经通道转载)
;;; ———————————————————————————
(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
(reerse 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
;;; 添加支持文件搜索路径
;;; ———————————————————————————
;;; note: 第二个参数如果为真, 插最前,否则插最后
;;;
(defun arbing_AddSupportPath (PathToAdd isFirst / supportlist)
(if(not
(l-string-search
(strcase (strcat pathToAdd “;”))
(strcase (strcat (geten “ACAD”) “;”))
)
); 保证不重复添加
(progn
(setq supportlist (strparse (geten “ACAD”) “;”))
(setq supportlist
(l-remoe-if-not
‘l-file-directory-p
supportlist
)
); 移除不存在的文件夹
(if isFirst
(setq supportlist (cons PathToAdd supportlist))
(setq supportlist (append supportlist (list PathToAdd)))
)
(seten “ACAD” (strUnParse supportlist “;”))
)
)
)
;;; 初始化主函数
;;; —————————————————
;;; 添加支持路径
(arbing_AddSupportPath (GetarbingPath) nil)
(arbing_AddSupportPath (strcat (GetarbingPath) “\ada”) nil)
;; 根据不同的AutoCAD版本加载不同的菜单文件。
(defun Load_arbingMenu (/ acader)
(setq acader (atof (getar “acader”)))
(cond
((and (>= acader 15.0) (< acader 16.0))
(command “_menuload” “arbing.mns”)
)
((and (>= acader 16.0) (<= acader 16.1))
(command “_menuload” “arbing2004.mns”)
)
((>= acader 16.2) (command “_menuload” “arbing2006.mns”))
)
)
;; 这个函数用来插入菜单条
;; The following code “placemenu” from LUCAS(龙龙仔)
(defun arbing_placemenu (/ n)
(if(menugroup “arbing”)
(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
;; 如需插入多条菜单,以反序在这里写:
;; 因只有一条下拉菜单,因此这里4,3条注释掉
;; (menucmd (strcat “p” (itoa n) “=+arbing.pop4″))
;; (menucmd (strcat “p” (itoa n) “=+arbing.pop3″))
;;(menucmd (strcat “p” (itoa n) “=+arbing.pop2″))
(menucmd (strcat “p” (itoa n) “=+arbing.pop1″))
(setq n 25)
);progn
);if
);while
);progn
);if
(princ)
)
;;; —————————————————–
;;; 主程序:
;;; —————————————————–
(princ “n采撷众家之开发精髓,打造精品之设计助手!n欢迎使用阿炳设计助手。正在加载,请稍候。”)
(setq arbing_cmdecho_sae (getar “cmdecho”))
(setar “cmdecho” 0)
;; 加载下拉菜单
(arbing_AddSupportPath (GetarbingPath) nil)
;; 如果菜单组还没有被加载,则加载之
(if (not (menugroup “arbing”))
(Load_arbingMenu)
)
;; 插到合适的位置
(arbing_placemenu)
(setar “cmdecho” arbing_cmdecho_sae)
(setq arbing_cmdecho_sae nil)
(princ)
) ;_end of defun initarbingApplication
(initarbingApplication)
;; 加载主程序
;; 为节省内存,这里也可以以autoload函数形式定义
;; 有几条写几条
(load “arbing.lx”)
(princ “n阿炳设计助手加载完毕。版本 2005.12″)
(princ “n阿炳设计助手联系邮箱:SBCSL@163.com。网址:http://arbing.wy8.net”)

怎样在指定的文件夹内建立文件

2010年08月31日,星期二

1、在D盘ACD文件夹内建立exc.dat文件
2、在exc文件写入“abcde”
3、读取exc文件,并将文件内容“abcde”赋与x
4、怎样判别当前坐标系是世界坐标系还是用户坐标系,如果是用户坐标系,又怎样获得X轴的方向
请大侠们帮个忙,分别给出能达到上面4个要求的函数

求助]请大家帮我看一下我的安装程序lisp问题出在哪里?

2010年08月31日,星期二

我根据秋枫兄创作的CAD二次通用安装制作程序制作了安装包,但程序运行后,既没有菜单加入,也没有支持路径加入。刚学lisp,请各位帮忙看一下问题出在哪里?谢谢。
;;; 判断是否加载本文件
(if (car (atoms-family 1 ‘(“l-load-com”)))
(l-load-com)
;;else
(progn
(Alert
“阿炳设计助手提示您:非常抱歉,这个程序集是为AutoCAD 2000以及更高的版本设计的,许多程序有可能在AutoCAD R14上不能正确地运行,建议您升级至2000以上版本。”
)
(exit) ; 版本不符,退出加载。
;; 首先定义初始化函数
(defun InitarbingApplication (/
;; 内部函数
GetMyApplicationPath GetarbingPath
strParse StrUnParse
arbing_AddSupportPath Load_arbingMenu
arbing_placemenu
;; 局部变量
arbing_cmdecho_sae
)
;;; 取得本程序的路径.
;;; 文件路径从注册表中读取,这些信息由安装程序负责写入注册表
;;; ———————————————————————————
(defun GetMyApplicationPath (AppID)
(l-registry-read
(strcat
“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentersion\Uninstall\”
AppID
“_is1″
)
“Inno Setup: App Path”
)
)
;; 这里取得安装后,安装的文件夹的绝对路径
;; 注意:这里的AppID为”阿炳设计助手”, 稍后的安装程序制作向导设置中必须与这里保持一致
(defun GetarbingPath ()
(GetMyApplicationPath “阿炳设计助手”)
)
;;; 解析字符串为表(函数来自明经通道转载)
;;; ———————————————————————————
(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
(reerse 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
;;; 添加支持文件搜索路径
;;; ———————————————————————————
;;; note: 第二个参数如果为真, 插最前,否则插最后
;;;
(defun arbing_AddSupportPath (PathToAdd isFirst / supportlist)
(if (not
(l-string-search
(strcase (strcat pathToAdd “;”))
(strcase (strcat (geten “ACAD”) “;”))
)
) ; 保证不重复添加
(progn
(setq supportlist (strparse (geten “ACAD”) “;”))
(setq supportlist
(l-remoe-if-not
‘l-file-directory-p
supportlist
)
) ; 移除不存在的文件夹
(if isFirst
(setq supportlist (cons PathToAdd supportlist))
(setq supportlist (append supportlist (list PathToAdd)))
)
(seten “ACAD” (strUnParse supportlist “;”))
)
)
)
;;; 初始化主函数
;;; —————————————————
;;; 添加支持路径
(arbing_AddSupportPath (GetarbingPath) nil)
(arbing_AddSupportPath (strcat (GetarbingPath) “\lsp”) nil)
(arbing_AddSupportPath (strcat (GetarbingPath) “\ada”) nil)
(arbing_AddSupportPath (strcat (GetarbingPath) “\lib”) nil)
;; 根据不同的AutoCAD版本加载不同的菜单文件。
(defun Load_arbingMenu (/ acader)
(setq acader (atof (getar “acader”)))
(cond
((and (>= acader 15.0) (< acader 16.0))
(command “_menuload” “arbing.mns”)
)
((and (>= acader 16.0) (<= acader 16.1))
(command “_menuload” “arbing2004.mns”)
)
((>= acader 16.2) (command “_menuload” “arbing2006.mns”))
)
)
;; 这个函数用来插入菜单条
;; The following code “placemenu” from LUCAS(龙龙仔)
(defun arbing_placemenu (/ n)
(if (menugroup “arbing”)
(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
;; 如需插入多条菜单,以反序在这里写:
;; 因只有一条下拉菜单,因此这里4,3条注释掉
;; (menucmd (strcat “p” (itoa n) “=+arbing.pop4″))
;; (menucmd (strcat “p” (itoa n) “=+arbing.pop3″))
;;(menucmd (strcat “p” (itoa n) “=+arbing.pop2″))
(menucmd (strcat “p” (itoa n) “=+arbing.pop1″))
(setq n 25)
) ;progn
) ;if
) ;while
) ;progn
) ;if
(princ)
)
;;; —————————————————–
;;; main:
;;; —————————————————–
(setq arbing_cmdecho_sae (getar “cmdecho”))
(setar “cmdecho” 0)
;; 加载下拉菜单
(arbing_AddSupportPath (GetarbingPath) nil)
;; 如果菜单组还没有被加载,则加载之
(if (not (menugroup “arbing”))
(Load_arbingMenu)
)
;; 插到合适的位置
(arbing_placemenu)
(setar “cmdecho” arbing_cmdecho_sae)
(setq arbing_cmdecho_sae nil)
(princ)
) ;_end of defun initarbingApplication
(initarbingApplication)
;; 加载主程序
;; 为节省内存,这里也可以以autoload函数形式定义
;; 有几条写几条
(load “arbing.lx”)
(princ)

怎样知道一个shx文件是否真的是字体文件?

2010年08月31日,星期二

经常有这样的文件:扩展名为shx,头信息也说是字体文件,可是就是不能定义为字体,谁知道如何彻底识别”庐山”真面目?

如何删除嵌套图块?

2010年08月31日,星期二

如何删除嵌套图块,如果使用purge命令,有三条限制:1 不能嵌套在另一个块中 2 不能嵌套在图形中 3 不能是附着的外部参照图形
有没有其它的方法,可以删除这样的嵌套图块,以不写lisp为优先考虑,我在《CAD软件使用技术》里求贴未应,认为能编lisp的高手肯定对命令和系统变量等早就灵活应用,如有违背本版规定的地方,请版主见谅,只求解答。

帮我改改这段小程序

2010年08月31日,星期二

1、(setq fp (open “d:/adc/dfp.dat” “r”)) ;打开d:/adc/路径的dfp.dat文件,如果dfp.dat文件不存在,则在此路径建立dfp.dat空文件
(setq txt (read-line fp)) ;将dfp.dat文件的内容赋于txt
(close fp) ;关闭文件
2、(setq as 12345) ;将实数12345赋与as
(setq fp (open “d:/adc/dfp.dat” “w”)) ;打开dfp.dat文件
(write-line as fp) ;将as写入并覆盖原内容
(close fp)
运行时在命令行提示”错误 : 参数类型错误: FILE nil”是怎么回事?
是不是文件里只能写入字符串,不能写入实数?