明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1982|回复: 4

帮忙改进

[复制链接]
发表于 2005-6-8 19:53 | 显示全部楼层 |阅读模式
自己编写了一段程序,但是测试很不稳定,有时候段不了线,有时候改不了图层,希望各位朋友帮忙改进,谢谢。 (defun c:YH_pipetype()
(setq pt1 (getpoint))
(setq selectcwx (ssget pt1))
(setq selectcwx (ssname selectcwx 0))
(setq selectcwx (entget selectcwx))
(setq layerYH (cdr (assoc 8 selectcwx)))
(cond
((= layerYH "S-雨水管")
(progn
(if (= (tblsearch "layer" "S-雨水") nil) (c:ys))
(setq YH_pipe "Y")
)
)
((= layerYH "S-污水管")
(progn
(if (= (tblsearch "layer" "S-污水") nil) (c:WS))
(setq YH_pipe "W")
)
)
((= layerYH "S-粪水管")
(progn
(if (= (tblsearch "layer" "S-粪水") nil) (c:FS))
(setq YH_pipe "F")
)
)
((= layerYH "S-冷凝水管")
(progn
(if (= (tblsearch "layer" "S-冷凝水") nil) (c:KT))
(setq YH_pipe "K")
)
)
((= layerYH "S-给水管")
(progn
(if (= (tblsearch "layer" "S-给水") nil) (c:JS))
(setq YH_pipe "J")
)
)
((= layerYH "S-消火栓管")
(progn
(if (= (tblsearch "layer" "S-消火栓") nil) (c:XH))
(setq YH_pipe "XH")
)
)
((= layerYH "S-喷淋管")
(progn
(if (= (tblsearch "layer" "S-喷淋") nil) (c:ZP))
(setq YH_pipe "ZP")
)
)
((= layerYH "S-通气管")
(progn
(if (= (tblsearch "layer" "S-通气") nil) (c:TQ))
(setq YH_pipe "T")
)
)
)
(if (= (tblsearch "style" "S-HZFS1") nil) (command "style" "S-HZFS1" "complex,hzfs1" "0" "0.6" "0" "n" "n"))
(command "text" "S" "S-HZFS1" "J" "M" pt1 "300" pause YH_pipe "")
(command "circle" pt1 (* 300 0.6))
(setq na (entlast))
(command "trim" na "" pt1 "")
(command "erase" na "")
(princ)
)
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2005-6-8 20:34 | 显示全部楼层
程序不全。



建议用复合线型修改。




本帖子中包含更多资源

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

x
 楼主| 发表于 2005-6-8 21:25 | 显示全部楼层
不会用复合线
1.我的是管线,一般都加粗的,复合线连字都加粗了,看不清楚。
2.我们专业的设计时间一般都超短,为了追求速度,很多东西都顾不上。有可能造成复合线里面的字是倒过来的
3.补充程序,希望大家帮我测试一下,谢谢。 ;;┏=====================================================┓
;;┃ 图层操作程序集 ┃
;;┃ 设计: 流浪水手 ┃
;;┗=====================================================┛ ;;--===================非打印辅助图层===================--
(defun c:SJ()
(laymcwx "S-给排水辅助图层" "100" "0.18")
(command "layer" "P" "N" "S-给排水辅助图层" "")
(princ)
) ;;创建给排水图层及字体
(defun c:GPS()
(laymcwx "S-给排水" "50" "0.18")
(MakeLayerFilter "给排水" "S-*")
(princ)
) ;;--===================给水===================--
(defun c:JS()
(laymcwx "S-给水" "131" "0.18")
) (defun c:JG()
(laymcwx "S-给水管" "131" "0.50")
(command "line")
(princ)
) (defun c:JX()
(laymcwx "S-给水管" "131" "0.50")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "linetype" "s" "dash" "" "line")
(princ)
)
;;--===================粪水===================--
(defun c:FS()
(laymcwx "S-粪水" "190" "0.18")
) (defun c:FG()
(laymcwx "S-粪水管" "190" "0.50")
(command "line")
(princ)
) (defun c:FX()
(laymcwx "S-粪水管" "190" "0.50")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "linetype" "s" "dash" "" "line")
(princ)
) ;;--===================污水===================--
(defun c:WS()
(laymcwx "S-污水" "160" "0.18")
) (defun c:WG()
(laymcwx "S-污水管" "160" "0.50")
(command "line")
(princ)
) (defun c:WX()
(laymcwx "S-污水管" "160" "0.50")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "linetype" "s" "dash" "" "line")
(princ)
) ;;--===================雨水===================--
(defun c:YS()
(laymcwx "S-雨水" "81" "0.18")
) (defun c:YG()
(laymcwx "S-雨水管" "81" "0.50")
(command "line")
(princ)
) (defun c:YX()
(laymcwx "S-雨水管" "81" "0.50")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "linetype" "s" "dash" "" "line")
(princ)
) ;;--===================冷凝水===================--
(defun c:KT()
(laymcwx "S-冷凝水" "60" "0.18")
) (defun c:KG()
(laymcwx "S-冷凝水管" "60" "0.50")
(command "line")
(princ)
) (defun c:KX()
(laymcwx "S-冷凝水管" "60" "0.50")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "linetype" "s" "dash" "" "line")
(princ)
) ;;--===================通气===================--
(defun c:TQ()
(laymcwx "S-通气" "255" "0.18")
) (defun c:TG()
(laymcwx "S-通气管" "255" "0.50")
(command "line")
(princ)
) ;;--===================消火栓===================--
(defun c:XH()
(laymcwx "S-消火栓" "30" "0.18")
) (defun c:XG()
(laymcwx "S-消火栓管" "30" "0.50")
(command "line")
(princ)
) ;;--===================喷淋===================--
(defun c:ZP()
(laymcwx "S-喷淋" "210" "0.18")
) (defun c:ZG()
(laymcwx "S-喷淋管" "210" "0.50")
(command "line")
(princ)
) (defun c:fz()
(laymcwx "S-喷头定位辅助线" "253" "0.18")
(command "linetype" "L" "dash" (strcat loadcwx "acad.lin") "" "" "layer" "L" "dash" pily "" "line")
(princ)
) (defun c:ZD()
(laymcwx "S-自喷标注" "210" "0.18")
) ;;--===================问题===================--
(defun c:WT()
(laymcwx "S-问题" "1" "0.18")
) ;;===================图层生成主函数======================
(defun laymcwx(laycwx colcwx liwcwx)
(setvar "CMDECHO" 0)
(command "linetype" "s" "bylayer" "" "color" "bylayer")
(command "layer" "m" laycwx "color" colcwx laycwx "LW" liwcwx laycwx "")
(princ)
) (defun c:pp()
(if (/= (tblsearch "layer" "S-给水管") nil)(command "layer" "color" "10" "S-给水管" ""))
(if (/= (tblsearch "layer" "S-污水管") nil)(command "layer" "color" "10" "S-污水管" ""))
(if (/= (tblsearch "layer" "S-粪水管") nil)(command "layer" "color" "10" "S-粪水管" ""))
(if (/= (tblsearch "layer" "S-雨水管") nil)(command "layer" "color" "10" "S-雨水管" ""))
(if (/= (tblsearch "layer" "S-消火栓管") nil)(command "layer" "color" "10" "S-消火栓管" ""))
(if (/= (tblsearch "layer" "S-喷淋管") nil)(command "layer" "color" "10" "S-喷淋管" ""))
(if (/= (tblsearch "layer" "S-冷凝水管") nil)(command "layer" "color" "10" "S-冷凝水管" ""))
(if (/= (tblsearch "layer" "S-通气管") nil)(command "layer" "color" "10" "S-通气管" ""))
(princ)
)
;;=============================锁定图层==================
(defun c:lc()
(setq selectcwx (entget (car (entsel))))
(setq layerYH (cdr (assoc 8 selectcwx)))
(command "layer" "lo" layerYH "")
(princ)
) ;;=============================解锁图层==================
(defun c:UL()
(setq selectcwx (entget (car (entsel))))
(setq layerYH (cdr (assoc 8 selectcwx)))
(command "layer" "U" layerYH "")
(princ)
) ;;=============================关闭图层==================
(defun c:OF()
(setq selectcwx (entget (car (entsel))))
(setq layerYH (cdr (assoc 8 selectcwx)))
(setq clycwx (getvar "clayer"))
(if (= layerYH clycwx)
(command "layer" "OFF" layerYH "Y" "")
(command "layer" "OFF" layerYH "")
)
(princ)
) ==========================生成给排水图层过滤器=================
(defun MakeLayerFilter (NAME FILTER / LayTbl ExtDict LayColl
ExtDictData GrpList NewDict Temp
XdLst XrecData NewXRec)
(vl-load-com) (setq LayTbl (cdr (assoc 330 (entget (tblobjname "LAYER" "0")))))
(setq ExtDict (cdr (assoc 360 (entget LayTbl)))) (if (not ExtDict)
(progn
(vl-load-com)
(setq LayColl (vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq ExtDict (vla-GetExtensionDictionary LayColl))
(setq ExtDict (vlax-vla-object->ename ExtDict))
)
) (setq ExtDictData (entget ExtDict)) (while ExtDictData
(setq Temp (if (= (caar ExtDictData) 3)
(list (cons (cdr (car ExtDictData))
(cdr (cadr ExtDictData))
)
)
)
ExtDictData (cdr ExtDictData)
)
(setq GrpList (append GrpList Temp))
) (if (or (not GrpList)
(not (cdr (assoc "ACAD_LAYERFILTERS" GrpList)))
)
(progn
(setq DictList (list (cons 0 "DICTIONARY")
(cons 100 "AcDbDictionary")))
(setq NewDict (entmakex DictList))
(setq NewDict (dictadd ExtDict "ACAD_LAYERFILTERS" NewDict))
)
(setq NewDict (cdr (assoc "ACAD_LAYERFILTERS" GrpList)))
)
(setq ExtDictData nil
Temp nil
GrpList nil
)
(setq ExtDictData (entget NewDict))
(while ExtDictData
(setq Temp (if (= (caar ExtDictData) 3)
(list (cons (cdr (car ExtDictData))
(cdr (cadr ExtDictData))))
)
ExtDictData (cdr ExtDictData)
)
(setq GrpList (append GrpList Temp))
) (if (or (not GrpList)
(not (cdr (assoc FILTER GrpList)))
)
(progn
(setq XdLst (list (cons 0 "XRECORD")
(cons 100 "AcDbXrecord")))
(setq XrecData (append XdLst
(list (cons 1 NAME)
(cons 1 FILTER)
(cons 1 "*")
(cons 1 "*")
(cons 70 0)
(cons 1 "*")
(cons 1 "*"))))
(setq NewXRec (entmakex XRecData))
(dictadd NewDict Name NewXRec)
)
nil
)
) ;;================锁定给排水图层====================
(defun c:gpsl()
(command "layer" "lo" "S-*" "")
(princ)
) ;;================解锁给排水图层====================
(defun c:gpsU()
(command "layer" "U" "S-*" "")
(princ)
) ;;================锁定非给排水图层==================
(defun c:jzl()
(command "layer" "lo" "*" "")
(C:gpsu)
(princ)
) ;;================解锁非给排水图层==================
(defun c:jzU()
(command "layer" "U" "*" "")
(C:gpsL)
(princ)
) (princ "\n图层操作程序加载成功......")
(princ)
 楼主| 发表于 2005-6-10 20:03 | 显示全部楼层
没人帮忙,只能靠自己了


我把程序的断线和插字顺序换了过来,问题得到缓解,不过偶尔还是段不开线,命令结束后还莫名其妙的说XXX命令为未知的。不过将就的用了。
发表于 2005-6-11 00:12 | 显示全部楼层
有个办法你可试试。



我是从R14一路过来的,在R14中打印是依颜色打印的而非线宽,这个打印方式一直用到现在。现在的ACAD版本仍然支持依颜色确定线条粗细打印。


你只需把不同组细的管线设定不同的颜色,而打印样式表中指定各个颜色的线粗(打印出来的线宽)、颜色(打印出来的颜色),那么你就可以随便应用复合线了。


不同的线粗、线型、图层应用不同的颜色,还可以使你看图时一目了然,即使所有的线都显示为实线时(用regen就能刷新)也无防。


并且好好的一根线变成一段一段的也不便编辑,而整根的就好多了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-12 20:09 , Processed in 0.174584 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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