明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6511|回复: 25

求一个写块小程序

  [复制链接]
发表于 2012-11-24 09:13:40 | 显示全部楼层 |阅读模式
1明经币
本帖最后由 半听可乐 于 2012-11-24 09:18 编辑

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

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

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

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

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

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

最佳答案

查看完整内容

(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 选择路径 #空军酒店 or #皮革城")) (if (= lj 1) (setq lj1 "D:\\APP\\快 ...
发表于 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)
)

再试
回复

使用道具 举报

发表于 2012-11-24 10:16:36 | 显示全部楼层
我的建议是把所有的图块放在一个文件里面,
用我已经共享程序,插入路径下这个文件里面的其中一个块,程序提示,输入你要的块名,基点连续插入
回复

使用道具 举报

 楼主| 发表于 2012-11-24 12:21:06 | 显示全部楼层
开心兄,你误会了,我想要的是从当前图纸中通过写块输出条件图,而不是要插块
回复

使用道具 举报

 楼主| 发表于 2012-11-24 18:40:17 | 显示全部楼层
保持可见性,自己顶起来
回复

使用道具 举报

发表于 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
(defun c:j()
(setq pold (getvar "pickfirst"))
(setq ti (rtos (getvar "cdate") 2 6))

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

回复

使用道具 举报

发表于 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
(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.写块的内容在原图上被删除了~~~

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

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-28 01:15 , Processed in 0.175595 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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