明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1687|回复: 5

[求助]图层定义处理出现的问题!

[复制链接]
发表于 2004-6-2 14:00:00 | 显示全部楼层 |阅读模式
图层的定义: (defun layset()
(command "layer" "n" "str,cen,hat,dim" "c" 3 "str" "c" 1 "cen" "c" 2 "dim" "c" 4 "hat" "")
(setq key (tblsearch "ltype" "center"))
(if (= key nil) (command "linetype" "l" "center" "acadiso" ""))
(command "layer" "lt" "center" "cen" "")
) 用该命令调用各图层:(setvar "clayer" "***")然后画图 然后完成一幅图!但是程序中有子程序(4个图),画完一幅之后再执行其它子程序(画其它图)的时候,各种图层线型起作用,但是图层颜色无效! 毕业设计的程序,请高手指教一下!急,明天答辩了!
发表于 2004-6-2 14:30:00 | 显示全部楼层
這個程序沒有問題. 你的意思是所畫的實體的顏色不隨層吧, 可能是你其它的程序有把所畫的實體改成其它顏色的.
发表于 2004-6-2 14:40:00 | 显示全部楼层
再看一下画图的时候颜色是否是随层的


本帖子中包含更多资源

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

x
 楼主| 发表于 2004-6-2 15:27:00 | 显示全部楼层
第一次运行的时候都是随层的,以后运行颜色就都不随层了! 我的齿轮绘图程序: (defun draw_gear1()
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(keyy)
(layset)
(setq ds d)
(setq bb key_w)
(setq t1 key_h)
(setq mn mn)
(setq z z)
(setq b w)
(setq d (* mn z))
(setq da (* mn (+ z 2)))
(setq df (* mn (- z 1.5)))
(setq D1 (* 1.6 ds))
(setq D2 (- da (* 10 mn)))
(setq D0 (* 0.5 (+ D1 D2)))
(setq dt0 (* 0.25 (- D2 D1)))
(setq c (* 0.3 b))
(setq n (* 0.5 mn))
(setq l (* 1.3 ds)) (setq pt1 (polar t0 (/ pi 2) (/ ds 2)))
(setq pt3 (polar pt1 0 (/ l 2)))
(setq pt31 (polar pt3 (/ pi 2) 2));倒角点,连接点
(setq pt2 (polar pt3 pi 2)) (setq pt4 (polar pt3 (/ pi 2) (/ (- D1 ds) 2))) (setq pt6 (polar pt4 pi (/ (- l c) 2)))
(setq pt7 (polar pt6 (/ pi 2) (/ (- D2 D1) 2)))
(setq pt8 (polar pt7 0 (/ (- b c) 2)))
(setq pt81 (polar pt8 (/ pi 2) 5));连接点
(setq pt5 (polar pt8 (/ (* 3 pi) 2) (/ (- D2 D1) 2)));pt5由pt8确定
(setq pt9 (polar pt8 (/ pi 2) (/ (- da D2) 2)))
(setq pt10 (polar pt9 pi (/ b 2)))
(setq pt11 (polar t0 (/ pi 2) (/ df 2)))
(setq pt12 (polar pt11 0 (/ b 2)))
(setq ps (polar t0 (/ pi 2) (/ d 2)));分度圆
(setq ps0 (polar ps 0 (+ (/ b 2) 4)));分度圆中心线
(setq ps1 (polar ps pi (+ (/ b 2) 4)));分度圆中心线 (setq pp2 (polar t0 0 (/ l 2)))
(setq pp1 (polar pp2 pi 2))
(setq pp3 (polar pp2 0 5));中线
(setq pp4 (polar pp2 pi (+ l 5)))
(setq pp5 (polar t0 (/ pi 2) (+ (/ da 2) 10)))
(setq pp6 (polar t0 (* pi 1.5) (+ (/ da 2) 10)))
(setq pp7 (polar t0 (/ pi 2) (/ D1 2)))
(setq pp8 (polar t0 (/ pi 2) (/ D2 2)))
(setq pp9 (polar t0 (* pi 1.5) (/ D1 2)))
(setq pp10 (polar t0 (* pi 1.5) (/ D2 2))) (setq pa (polar t0 (/ pi 2) (/ D0 2)))
(setq pa0 (polar pa 0 (+ (/ c 2) 4)));孔中心线确定点
(setq pa6 (polar pa pi (+ (/ c 2) 4)))
(setq pa5 (polar pa pi (+ (/ c 2) 4)));孔中心线确定点
(setq pa4 (polar pa (/ pi 2) (/ dt0 2)))
(setq pa1 (polar pa (* pi 1.5) (/ dt0 2)))
(setq pa3 (polar pa4 0 (/ c 2)))
(setq pa2 (polar pa1 0 (/ c 2)))

(setvar "clayer" "str")
(command "line" pt1 pt2 "")
(setq e1 (entlast))
(command "line" pt2 pt31 "");直接连线当倒角
(command "pline" pt31 pt4 pt6 pt7 pt8 pt9 pt10 "")
(setq e2 (entlast))
(command "line" pp2 pt31 "")
(setq e3 (entlast))
(command "line" pt5 pt81 "")
(setq e4 (entlast))
(command "line" pp1 pt2 "")
(command "line" pa4 pa3 "")
(command "line" pa1 pa2 "")
(command "line" pt11 pt12 "")
(command "fillet" "r" "2");定义倒圆角为半径为2
(command "fillet" "p" e2);为多义线角 (command "mirror" "all" "" pt10 pt1 "");像 (command "mirror" "all" "" pp2 pp1 "");完整像 ;---------------------------------------------------以下为侧视图
(setq pc (polar pp2 0 (+ (/ da 2) b)))
(setq tt (+ (/ ds 2) t1))
(setq pc1 (polar pc 0 (/ ds 2)))
(setq pc2 (polar pc 0 (+ (/ ds 2) 2)))
(setq pc3 (polar pc (* 1.75 pi) (/ ds 2)))
(setq pn1 (polar pc (/ pi 2) (/ bb 2)))
(setq pn2 (polar pc (* pi 1.5) (/ bb 2)))
(setq pn3 (polar pn2 0 tt))
(setq pn4 (polar pn1 0 tt))
(setq pk1 (polar pc 0 (/ D1 2)))
(setq pk2 (polar pc 0 (/ D0 2)))
(setq pk3 (polar pk2 0 (/ dt0 2)))
(setq pk4 (polar pc 0 (/ D2 2)))
(setq pk5 (polar pc 0 (/ d 2)))
(setq pk6 (polar pc 0 (/ da 2)))
(setq pk7 (polar pk2 (/ pi 6) (/ dt0 2)))

;中心线确点
(setq pc5 (polar pc 0 (+ (/ da 2) 10)))
(setq pc6 (polar pc pi (+ (/ da 2) 10)))
(setq pc7 (polar pc (/ pi 2) (+ (/ da 2) 10)))
(setq pc8 (polar pc (* pi 1.5) (+ (/ da 2) 10)))
(command "circle" pc (/ ds 2))
(setq c1 (entlast))
(command "circle" pc (+ (/ ds 2) 2))
(setq c2 (entlast))
(command "line" pn2 pn3 "")
(setq l1 (entlast))
(command "line" pn1 pn4 "")
(setq l2 (entlast))
(command "line" pn3 pn4 "")
(setq l3 (entlast))
(command "trim" c1 c2 l1 l2 l3 "" pc1 pc2 pn1 pn2 "")
(command "trim" c1 c2 l1 l2 l3 "" pc1 pc2 pn1 pn2 "")
;(command "rotate" c1 c2 l1 l2 l3 "" pc pc3 "") (command "circle" pc (/ D1 2))
(command "circle" pc (/ D0 2));保留
(command "circle" pc (/ D2 2)) (command "circle" pc (/ da 2))
(command "circle" pk2 (/ dt0 2))
(setq c3 (entlast))
(command "array" c3 "" "p" pc "4" "" "n")
(command "color" "3") (setvar "clayer" "hat") (command "-bhatch" "p" "ansi31" "1" "0" pp8 "");绘制剖面线
(command "-bhatch" "p" "ansi31" "1" "0" pp7 "")
(command "-bhatch" "p" "ansi31" "1" "0" pp9 "");绘制剖面线
(command "-bhatch" "p" "ansi31" "1" "0" pp10 "") ;------------------------------------------------画线 (setvar "clayer" "cen")
(command "line" pa6 pa0 "")
(setq cl1 (entlast))
(command "line" ps1 ps0 "")
(setq cl2 (entlast))
(command "line" pp3 pp4 "")
(command "mirror" cl1 cl2 "" pp3 pp4 "")
(command "line" pp5 pp6 "")
(command "line" pc5 pc6 "")
(command "line" pc7 pc8 "")
(command "circle" pc (/ d 2));分度圆 ;-------------------------------------------------执行标注尺寸序 ;------------------------------------块
(setvar "clayer" "dim")
;------------------------------------------标点

(setq pd1 (polar pt6 pi (/ b 2)))
(setq pd2 (polar pd1 (* 1.5 pi) D1))
(setq pd3 (polar pt7 pi (/ b 2)))
(setq pd4 (polar pd3 (* 1.5 pi) D2))
(setq ps1 (polar ps (* 1.5 pi) d))
(setq pd10 (polar pt10 (* 1.5 pi) da))
(setq pd12 (polar pt12 pi b))
(setq pd0 (polar pa0 (* 1.5 pi) D0))
(setq pd6 (polar pt1 pi (/ c 2)))
(setq pd7 (polar pd6 (* pi 1.5) ds))
(setq pd8 (polar pa3 pi c))
(setq pt32 (polar pt31 pi l)) (command "dimlinear" pd1 pd2 "t" "%%c<>" (polar pd1 pi (+ (/ c 2) 16)));D1
(command "dimlinear" pd3 pd4 "t" "%%c<>" (polar pd3 pi (+ (/ c 2) 24)));D2
(command "dimlinear" ps ps1 "t" "%%c<>" (polar ps pi (+ (/ b 2) 30)));
(command "dimlinear" pt10 pd10 "t" "%%c<>" (polar pt10 pi (+ (/ b 2) 38)));da
(command "dimlinear" pa0 pd0 "t" "%%c<>" (polar pa 0 (+ (/ b 2) 32)));D0
(command "dimlinear" pd6 pd7 "t" "%%c<>" (polar pd6 0 0));ds
(command "dimlinear" pa3 pd8 (polar pa3 (/ pi 2) (+(- (/ (- da D0) 2) (/ dt0 2)) 8)));c
(command "dimlinear" pt12 pd12 (polar pt12 (/ pi 2) 20));B
(command "dimlinear" pt31 pt32 (polar pt31 (/ pi 2) (+(/ (- da ds) 2) 30)));L
(command "dimdiameter" pk7 pk7)
(setq ccd "3.2")
(setq ch 3.5)
(setq ch1 (* ch 1.61658))
(setq cp1 (polar t0 (/ pi 3) (* 2 ch1)))
(setq cp2 (polar t0 (/ pi 3) ch1))
(setq cp3 (polar cp2 pi ch1))
(setq cp4 (polar t0 (/ pi 2) (* 1.4 ch1)))
(command "pline" cp2 cp3 t0 cp1 "")
(setq cc1 (entlast))
(command "text" "m" cp4 ch "0" ccd)
(setq cc2 (entlast))
(setq bkey(tblsearch "block" "c32"))
(if (= bkey nil)(command "-block" "c32" t0 cc1 cc2 "")) (setq cp5 (polar pt10 0 (/ b 3)));粗糙度标注点1
(setq cp6 (polar pt1 0 (/ b 3)))
(setq cp7 (polar cp6 (* pi 1.5) ds));粗糙度标注点2
(setq cp8 (polar pt5 (* pi 1.5) (+ D1 dt0)))
(setq cp9 (polar cp8 pi b));粗糙度标注点3(90度) (command "insert" "c32" cp5 "" "" "")
(command "insert" "c32" cp7 "" "" "")
(command "insert" "c32" "r" "90" cp9 "" "" "") (command "zoom" "a" )
) 图形画出来以后,删掉图形再运行就会出现不颜色随层问题! 请帮我看看,谢谢!
发表于 2004-6-2 15:43:00 | 显示全部楼层
發現你的程序里面把用這樣(command "color" "3")就把當前層改成不隨層了.所以就出現你說的錯誤, 你把他們刪去就行了
 楼主| 发表于 2004-6-2 19:20:00 | 显示全部楼层
真的,我改好了,没问题了!太谢谢了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-6 07:16 , Processed in 0.156352 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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