找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 385|回复: 0

[求助]:如何完善这个程序

[复制链接]
发表于 2006-6-10 23:38:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
以下是以前比较旧的统计图块的LISP程序,请问如何把生成的文件放在指定的目录里了,求教各位高手?

;Blcount.LSP: Counts the blocks in a drawing then stores the count in a
;             file of the same name as the drawing and the .BLC extension.
;___________________________________________________________________________

(defun lststr (str / pos numlst chr len wrd wrdlst)
(setq pos 1)
(setq numlst '())
(setq wrdlst '())
(setq chr (substr str pos 1))
(while (/= chr "")
    (if (= chr ",")
       (setq numlst (append numlst (list pos)))
    )
  (setq pos (1+ pos))
  (setq chr (substr str pos 1))
);while
(setq numlst (append numlst (list (1+ (strlen str)))))
(setq pos 1)
(setq len (1- (car numlst)))
(setq wrd (substr str pos len))
(while (/= wrd "")
  (setq wrdlst (append wrdlst (list wrd)))
  (setq pos (1+ (car numlst)))
  (if (> (length numlst) 1)
    (setq len (1- (- (cadr numlst) (car numlst) )) )
  )
  (setq numlst (cdr numlst))
  (setq wrd (substr str pos len))
)
wrdlst
)


(Defun addsp (strn / scount)
(setq scount (strlen strn))
(repeat (- 10 scount)
  (setq strn (strcat strn " "))
)
strn
)

(defun c:blcount (/ record blnme name v1 filnme outfl blklst bllst blist)
(SETVAR "CMDECHO" 0)
(setq filnme (strcat (getvar "dwgname") ".blc"))
(setq blist (STRCASE (getstring "\nEnter name(s) of blocks to count or RETURN for all: ")))
(if (= Blist "")
  (setq record (cdr (assoc 2 (tblnext "block" t))))
  (setq record (car (setq blist2 (lststr blist))))
)
(setq blklst '())
(princ "\nSearching for blocks... Please wait.  ")
(while record
   (setq blnme (cons 2 record))
   (setq v1 (ssget "x" (list blnme) ))
     (if v1
        (progn
        (setq bllst (strcat (addsp record) "\t" (itoa (sslength v1)) "\n"))
        (princ bllst)
        (setq blklst (append blklst (list bllst)))
        );progn
     );if
     (if (= Blist "")
        (setq record (cdr (assoc 2 (tblnext "block"))))
        (progn
          (setq blist2 (cdr blist2))
          (setq record (car blist2))
        )
     )
(princ "\nSearching for blocks... Please wait.  ")
);while
(princ "\nWriting block count to ")(princ filnme)
(setq outfl (open filnme "w"))
(foreach n blklst (princ n outfl))
(close outfl)
(princ)
)



论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-25 04:50 , Processed in 0.366446 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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