半听可乐 发表于 2012-11-24 09:13:40

求一个写块小程序

本帖最后由 半听可乐 于 2012-11-24 09:18 编辑

工作中经常用到wblock(写块方式为保留)互相提条件图,每次用这个命令要找路径很麻烦,可不可以用lisp实现这样的功能:

1.在程序中预设几个路径,运行程序后能提示选择哪个路径。比如有路径1:      D:\项目\图纸\#空军酒店\【提图】
                                                                                                         路径2:      D:\项目\图纸\#阳光家园\【提图】

运行程序后提示:选择路径--1(空军酒店)/2(阳光家园),然后输入2,写块写到D:\项目\图纸\#阳光家园\【提图】

2.写完块之后目标文件夹被打开,这样方便给其他人传图

使用步骤:1.输入命令,框选需要写块的范围(这两个小步骤不分先后更好)
                  2.输入文件名(如果能自动添加当前日期后缀更好,如输入“平面图”,写块后为“平面图11.24.dwg”)
                  3.通过数字选择预设路径
                  4.写块(写块方式为保留)到预设路径,同时目标文件夹被打开

打完这些字,感觉这应该是个不小的程序~~~~呵呵,敬侯高手!

phoenixdjq 发表于 2012-11-24 09:13:41

(defun c:jjj()


(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))
(setq yy (substr ti 3 2))
(setq mm (substr ti 5 2))
(setq dd (substr ti 7 2))

(vl-load-com)
(command "md" "D:\\APP\\快盘\\#空军酒店\\【水提图】")
(command "md" "D:\\APP\\快盘\\#皮革城\\【水提图】")

(setq lj (getint "\n 选择路径 #空军酒店<1> or#皮革城<2>"))



(if (= lj 1)
(setq lj1 "D:\\APP\\快盘\\#空军酒店\\【水提图】\\")
(setq lj1 "D:\\APP\\快盘\\#皮革城\\【水提图】\\")
)

(command "-block" (setq mingzi (getstring "\n 输入块名:"))pause (ssget) "")
(setq wenjianming (strcat lj1 mingzi yy mm dd ".dwg"))
(command "-wblock"wenjianming mingzi)

(if (= lj 1)
(startapp "explorer.exe" "D:\\APP\\快盘\\#空军酒店\\【水提图】")
(startapp "explorer.exe" "D:\\APP\\快盘\\#皮革城\\【水提图】")
)

(setvar "pickfirst" pold)
)

再试

【KAIXIN】 发表于 2012-11-24 10:16:36

我的建议是把所有的图块放在一个文件里面,
用我已经共享程序,插入路径下这个文件里面的其中一个块,程序提示,输入你要的块名,基点连续插入

半听可乐 发表于 2012-11-24 12:21:06

开心兄,你误会了,我想要的是从当前图纸中通过写块输出条件图,而不是要插块

半听可乐 发表于 2012-11-24 18:40:17

保持可见性,自己顶起来

phoenixdjq 发表于 2012-11-25 13:29:05

(defun c:j()
(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))
(setq yy (substr ti 3 2))
(setq mm (substr ti 5 2))
(setq dd (substr ti 7 2))

(vl-load-com)

(command "md" "D:\\项目\\图纸\\#空军酒店")
(command "md" "D:\\项目\\图纸\\#阳光家园")

(setq lj (getint "\n 选择路径 D:\\项目\\图纸\\#空军酒店\\-<1> or D:\\项目\\图纸\\#阳光家园\\-<2>"))



(if (= lj 1)
(setq lj1 "D:\\项目\\图纸\\#空军酒店\\")
(setq lj1 "D:\\项目\\图纸\\#阳光家园\\")
)

(vl-cmdf "-block"(setq mingzi (getstring "\n 输入块名:"))pause pause "")
(setq wenjianming (strcat lj1 mingzi yy mm dd ".dwg"))
(command "-wblock"wenjianming mingzi)
(setvar "pickfirst" pold)
)

阿然 发表于 2012-11-25 14:56:16

本帖最后由 阿然 于 2012-11-25 14:56 编辑

参考ACAD中按CTRL+3,应该可以满足你的要求

半听可乐 发表于 2012-11-26 00:16:43

phoenixdjq 发表于 2012-11-25 13:29 static/image/common/back.gif
(defun c:j()
(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))


感谢大侠热心相助,经试用发现两个小问题:1.不能选择需要写块的图元
2.写块完成后相应文件夹没有打开
3.提示路径时希望只出现项目名称,如“#阳光家园”,而不是“D:\项目\图纸\#阳光家园\【提图】”
希望大侠继续帮忙

phoenixdjq 发表于 2012-11-26 08:58:36

(defun c:j()


(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))
(setq yy (substr ti 3 2))
(setq mm (substr ti 5 2))
(setq dd (substr ti 7 2))

(vl-load-com)

(command "md" "D:\\项目\\图纸\\#空军酒店")
(command "md" "D:\\项目\\图纸\\#阳光家园")

(setq lj (getint "\n 选择路径 #空军酒店<1> or#阳光家园<2>"))



(if (= lj 1)
(setq lj1 "D:\\项目\\图纸\\#空军酒店\\")
(setq lj1 "D:\\项目\\图纸\\#阳光家园\\")
)

(command "-block" (setq mingzi (getstring "\n 输入块名:"))pause (ssget) "")
(setq wenjianming (strcat lj1 mingzi yy mm dd ".dwg"))
(command "-wblock"wenjianming mingzi)

(if (= lj 1)
(startapp "explorer.exe" "D:\\项目\\图纸\\#空军酒店")
(startapp "explorer.exe" "D:\\项目\\图纸\\#阳光家园")
)

(setvar "pickfirst" pold)
)



再试试看

半听可乐 发表于 2012-11-26 09:20:01

本帖最后由 半听可乐 于 2012-11-26 09:23 编辑

phoenixdjq 发表于 2012-11-26 08:58 http://bbs.mjtd.com/static/image/common/back.gif
(defun c:j()




(defun c:jjj()


(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))
(setq yy (substr ti 3 2))
(setq mm (substr ti 5 2))
(setq dd (substr ti 7 2))

(vl-load-com)
(command "md" "D:\\APP\\快盘\\#空军酒店\\【水提图】")
(command "md" "D:\\APP\\快盘\\#皮革城\\【水提图】")

(setq lj (getint "\n 选择路径 #空军酒店<1> or#皮革城<2>"))



(if (= lj 1)
(setq lj1 "D:\\APP\\快盘\\#空军酒店\\【水提图】")
(setq lj1 "D:\\APP\\快盘\\#皮革城\\【水提图】")
)

(command "-block" (setq mingzi (getstring "\n 输入块名:"))pause (ssget) "")
(setq wenjianming (strcat lj1 mingzi yy mm dd ".dwg"))
(command "-wblock"wenjianming mingzi)

(if (= lj 1)
(startapp "explorer.exe" "D:\\APP\\快盘\\#空军酒店\\【水提图】")
(startapp "explorer.exe" "D:\\APP\\快盘\\#皮革城\\【水提图】")
)

(setvar "pickfirst" pold)
)


一大早就帮我,感动至极!
我把路径改了一下,还是有点小问题:
1.输完块名后不能用空格确定(回车可以)
2.块写进的是“【水提图】”上一级文件夹
3.保存的文件名被冠上了“【水提图】”的前缀
4.写块的内容在原图上被删除了~~~

其他都很好,有劳再帮我完善一下

页: [1] 2 3
查看完整版本: 求一个写块小程序