请教:关于emake
;;请教:关于emake;;定义子函数(sf-entmake-arc)
(defun sf-entmake-arc (cen rad startpt endpt layer color xx)
(entmakex
(list '(000 . "ARC")
'(100 . "AcDbEntity")
'(100 . "AcDbCircle")
'(100 . "AcDbArc")
(cons 8 layer)
(cons 6 color)
(cons 6 xx)
(cons 10 cen)
(cons 40 rad)
(cons 50
(if (listp startpt)
(angle cen startpt)
startpt
)
)
(cons 51
(if (listp endpt)
(angle cen endpt)
endpt
)
)
)
)
)
;;调用子函数(sf-entmake-arc)
(setq en (sf-entmake-arc pt2 (setq r (1+ r)) (polar pt2 0 r) (polar pt2 ang r) "0" 1 "ByBlock")
如果子函数(sf-entmake-arc)的参数(layer)赋值时不用数字:1,改用:("ByBlock"、"ByLayer"), 如:
(setq en (sf-entmake-arc pt2 (setq r (1+ r)) (polar pt2 0 r) (polar pt2 ang r) "0" "ByBlock" "ByBlock")
子函数(sf-entmake-arc)的代码该如何修改?
把颜色改成0就可以了 ;;定义子函数(sf-entmake-arc)
(defun sf-entmake-arc (cen rad startpt endpt layer color xx)
; 将颜色参数转换为适当的格式
(setq color (cond
((equal color "ByBlock") 0) ; "ByBlock" 转换为 0
((equal color "ByLayer") 256) ; "ByLayer" 转换为 256
(T color)
)
) ; 否则保持原值
(entmakex
(list '(000 . "ARC")
'(100 . "AcDbEntity")
'(100 . "AcDbCircle")
'(100 . "AcDbArc")
(cons 8 layer)
(cons 62 color)
(cons 6 xx)
(cons 10 cen)
(cons 40 rad)
(cons 50
(if (listp startpt)
(angle cen startpt)
startpt
)
)
(cons 51
(if (listp endpt)
(angle cen endpt)
endpt
)
)
)
)
)
;以下测试通过
(defun c:tt ()
(sf-entmake-arc
'(0 0) ; 圆弧中心
500 ; 半径
'(500 0); 起始点
'(0 500); 结束点
"ByBlock"; 图层
"ByBlock" ; 颜色
"ByBlock" ; 线型
)
)
页:
[1]