明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1772|回复: 6

『求助』无法完成填充。不知道哪里错了,帮我看下好吗?(急)

[复制链接]
发表于 2005-5-14 21:35:00 | 显示全部楼层 |阅读模式
程序的局部。因为我不完全懂SSADD等等。哪位热心人能帮我看下吗 谢谢 (setq pt0 (getpoint "\n灯杆底部位置:"))
(setq gd (getpoint "\n灯高位置:"))
(setq xx (car pt0) yy (cadr pt0))
(setq xt (car gd) yt (cadr gd))
(setq aa1 (angle pt0 gd))
(setq bb1 (distance pt0 gd))
(setq bb2 (* bb1 (sin aa1)))
(setq bb (/ bb2 18))
(setq xx (car pt0) yy (cadr pt0))
(setq xt (car gd) yt (cadr gd))
(setq aa1 (angle pt0 gd))
(setq bb1 (distance pt0 gd))
(setq bb2 (* bb1 (sin aa1)))
(setq bb (/ bb2 18))
(setq pt1 (list (+ xx (* bb 1)) yy ))
(setq pt2 (list (+ xx (* bb 0.7)) (+ yy (* bb 2.8))))
(setq pt3 (list (car pt2) (+ (* bb 0.9) (cadr pt2))))
(setq pt4 (list (+ xx (* bb 0.35)) (+ (* bb 0.9) (cadr pt3))))
(setq pt5 (list (car pt4) (+ (* bb 10.4) (cadr pt4))))
(setq pt6 (list (+ (car pt5) (* bb 0.1)) (cadr pt5)))
(setq pt7 (list (car pt6) (+ (* bb 1.8) (cadr pt6))))
(setq pt8 (list (- (car pt7) (* bb 0.15)) (+ (cadr pt7) (* bb 0.5))))
(setq pt9 (list xx (cadr pt8)))
(setq pt10 (list (+ (car pt7) (* bb 0.9)) (cadr pt7)))
(setq pt11 (list (+ (car pt10) (* bb 3)) (+ (cadr pt10) (* bb 0.66))))
(setvar "cecolor" (rtos cc1))
(command "line" pt0 pt1 "")
(setq sum (ssadd) first (entlast))
(ssadd (entlast) sum)
(command "arc" pt1 "e" pt2 "a" -31)
(ssadd (entlast) sum)
(command "pline" pt2 pt3 "")
(ssadd (entlast) sum)
(command "arc" pt3 "e" pt4 "a" 118)
(ssadd (entlast) sum)
(command "pline" pt4 pt5 pt6 pt7 "")
(ssadd (entlast) sum)
(command "arc" pt7 "e" pt8 "a" 90)
(ssadd (entlast) sum)
(command "pline" pt8 pt9 "")
(ssadd (entlast) sum)
(command "pline" pt7 pt10 "")
(ssadd (entlast) sum)
(command "arc" pt10 "e" pt11 "a" 160)
(ssadd (entlast) sum)
(command "mirror" sum "" pt0 pt9 "")
(ssadd (entlast) sum)
(setvar "cecolor" (rtos cc1))
(command "hatch" "solid" sum "")
(setq pt12 (polar pt9 (/ pi 2) (* bb 0.3)))
(command "pline" pt9 "w" 3 0 pt12 "")
发表于 2005-5-14 22:26:00 | 显示全部楼层
(defun c:dd ()
;;我修改后程序可顺利运行结束
(setq pt0 (getpoint "\n灯杆底部位置:"))
(setq gd (getpoint "\n灯高位置:"))
(setq xx (car pt0)
yy (cadr pt0)
)
(setq xt (car gd)
yt (cadr gd)
)
(setq aa1 (angle pt0 gd))
(setq bb1 (distance pt0 gd))
(setq bb2 (* bb1 (sin aa1)))
(setq bb (/ bb2 18))
(setq xx (car pt0)
yy (cadr pt0)
)
(setq xt (car gd)
yt (cadr gd)
)
(setq aa1 (angle pt0 gd))
(setq bb1 (distance pt0 gd))
(setq bb2 (* bb1 (sin aa1)))
(setq bb (/ bb2 18))
(setq pt1 (list (+ xx (* bb 1)) yy))
(setq pt2 (list (+ xx (* bb 0.7)) (+ yy (* bb 2.8))))
(setq pt3 (list (car pt2) (+ (* bb 0.9) (cadr pt2))))
(setq pt4 (list (+ xx (* bb 0.35)) (+ (* bb 0.9) (cadr pt3))))
(setq pt5 (list (car pt4) (+ (* bb 10.4) (cadr pt4))))
(setq pt6 (list (+ (car pt5) (* bb 0.1)) (cadr pt5)))
(setq pt7 (list (car pt6) (+ (* bb 1.8) (cadr pt6))))
(setq pt8 (list (- (car pt7) (* bb 0.15)) (+ (cadr pt7) (* bb 0.5))))
(setq pt9 (list xx (cadr pt8)))
(setq pt10 (list (+ (car pt7) (* bb 0.9)) (cadr pt7)))
(setq pt11 (list (+ (car pt10) (* bb 3)) (+ (cadr pt10) (* bb 0.66))))
;;;;;;;;;;;;;;;;;;;;;;;;
;;(setvar "cecolor" (rtos cc1))
;;(rtos cc1)出错,因为CCL为NIL
(setvar "cecolor" "7")
;;;;;;;;;;;;;;;;;;;
(command "line" pt0 pt1 "")
(setq sum (ssadd)
first (entlast)
)
(ssadd (entlast) sum)
(command "arc" pt1 "e" pt2 "a" -31)
(ssadd (entlast) sum)
(command "pline" pt2 pt3 "")
(ssadd (entlast) sum)
(command "arc" pt3 "e" pt4 "a" 118)
(ssadd (entlast) sum)
(command "pline" pt4 pt5 pt6 pt7 "")
(ssadd (entlast) sum)
(command "arc" pt7 "e" pt8 "a" 90)
(ssadd (entlast) sum)
(command "pline" pt8 pt9 "")
(ssadd (entlast) sum)
(command "pline" pt7 pt10 "")
(ssadd (entlast) sum)
(command "arc" pt10 "e" pt11 "a" 160)
(ssadd (entlast) sum)
(command "mirror" sum "" pt0 pt9 "")
(ssadd (entlast) sum)
;;;;;;;;;;;;;;;;;;;;;
;;(setvar "cecolor" (rtos cc1))
;;(rtos cc1)出错,因为CCL为NIL
(setvar "cecolor" "7")
;;;;;;;;;;;;;;;;;;;;
(command "hatch" "solid" sum "")
(setq pt12 (polar pt9 (/ pi 2) (* bb 0.3)))
(command "pline" pt9 "w" 3 0 pt12 "")
(princ)
)
发表于 2005-5-14 22:44:00 | 显示全部楼层
不能填充是因为你的填充边界多选几个物体进去了,所以出错,我将程序部份作了一些调整,以作参考。
  1. (defun c:test ()
  2.    (setq pt0 (getpoint "\n灯杆底部位置:"))
  3.    (setq gd (getpoint pt0 "\n灯高位置:"))
  4.    (setq os (getvar "osmode"))
  5.    (setvar "cmdecho" 0)
  6.    (setvar "osmode" 0)
  7.    (setq  xx (car pt0)
  8.   yy (cadr pt0)
  9.    )
  10.    (setq  xt (car gd)
  11.   yt (cadr gd)
  12.    )
  13.    (setq aa1 (angle pt0 gd))
  14.    (setq bb1 (distance pt0 gd))
  15.    (setq bb2 (* bb1 (sin aa1)))
  16.    (setq bb (/ bb2 18))
  17.    (setq  xx (car pt0)
  18.   yy (cadr pt0)
  19.    )
  20.    (setq  xt (car gd)
  21.   yt (cadr gd)
  22.    )
  23.    (setq aa1 (angle pt0 gd))
  24.    (setq bb1 (distance pt0 gd))
  25.    (setq bb2 (* bb1 (sin aa1)))
  26.    (setq bb (/ bb2 18))
  27.    (setq pt1 (list (+ xx (* bb 1)) yy))
  28.    (setq pt2 (list (+ xx (* bb 0.7)) (+ yy (* bb 2.8))))
  29.    (setq pt3 (list (car pt2) (+ (* bb 0.9) (cadr pt2))))
  30.    (setq pt4 (list (+ xx (* bb 0.35)) (+ (* bb 0.9) (cadr pt3))))
  31.    (setq pt5 (list (car pt4) (+ (* bb 10.4) (cadr pt4))))
  32.    (setq pt6 (list (+ (car pt5) (* bb 0.1)) (cadr pt5)))
  33.    (setq pt7 (list (car pt6) (+ (* bb 1.8) (cadr pt6))))
  34.    (setq pt8 (list (- (car pt7) (* bb 0.15)) (+ (cadr pt7) (* bb 0.5))))
  35.    (setq pt9 (list xx (cadr pt8)))
  36.    (setq pt10 (list (+ (car pt7) (* bb 0.9)) (cadr pt7)))
  37.    (setq pt11 (list (+ (car pt10) (* bb 3)) (+ (cadr pt10) (* bb 0.66))))
  38.    ;;(setvar "cecolor" (rtos cc1))
  39.    (setq ent (entlast))
  40.    (setq sum (ssadd))
  41.    (command "line" pt0 pt1 "")
  42.    (command "arc" pt1 "e" pt2 "a" -31)
  43.    (command "pline" pt2 pt3 "")
  44.    (command "arc" pt3 "e" pt4 "a" 118)
  45.    (command "pline" pt4 pt5 pt6 pt7 "")
  46.    (command "arc" pt7 "e" pt8 "a" 90)
  47.    (command "pline" pt8 pt9 "")
  48.    (command "pline" pt7 pt10 "")
  49.    (command "arc" pt10 "e" pt11 "a" 160)
  50.    (if (= ent nil)
  51.        (setq sum (ssget "all"))
  52.        (while (setq ent (entnext ent))
  53.            (ssadd ent sum)
  54.        )
  55.    )
  56.    (command "mirror" sum "" pt0 pt9 "")
  57.    (setq pnt (polar pt0 (angle pt0 pt9) 1))
  58.    ;; (setvar "cecolor" (rtos cc1))
  59.    ;;(command "hatch" "solid" sum "")
  60.    (command "bhatch" "p" "solid" pnt "")
  61.    (setq pt12 (polar pt9 (/ pi 2) (* bb 0.3)))
  62.    (command "pline" pt9 "w" 3 0 pt12 "")
  63.    (setvar "osmode" os)
  64.    (setvar "cmdecho" 1)   (princ)
  65. )
 楼主| 发表于 2005-5-15 00:03:00 | 显示全部楼层
太感谢两位大侠了,我不是很明白ssadd的用法


比如说我们需要保存每次画的线在选择集里面,然后对集合里面的整体做动作,是不是这个意思呢,用ssadd。


还有我上面发的程序里没定义cc1等颜色,这个是局部,所以我没写上来。
 楼主| 发表于 2005-5-15 00:06:00 | 显示全部楼层
看了二位的修改程序,更觉得我是个菜鸟了,受益匪浅。不过也就是应付毕业设计,没有办法。不过以后有机会还是学学lisp,挺不错的。
发表于 2005-5-15 00:47:00 | 显示全部楼层
看了二位的程序,我也觉得我是菜鸟了:((((
 楼主| 发表于 2005-5-15 12:02:00 | 显示全部楼层
能不能把填充颜色设置成渐变色呢? 如何操作呢?

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

本版积分规则

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

GMT+8, 2024-11-17 06:48 , Processed in 0.158101 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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