AutoLisp 绘制服装折线
AutoLisp drawing costum polyline
我有这个 AutoLisp 代码,我想问 2 个问题:
1.如何在绘制过程中(或选择点时)使多段线可见?
2。我怎样才能改变折线的颜色而不是层的颜色?
如果我得到答案,非常感谢。
(defun c:nyomvodal (/ osmode clayer celtype)
;; save the current osmode, clayer and celtype
(setq osmode (getvar "osmode"))
(setq clayer (getvar "clayer"))
(setq celtype (getvar "celtype"))
;; create a new layer and make it current
(command "_layer" "_make" "nyomvodal" "_color" 3 "nyomvodal" "")
;; set the current osmode and line type
(setvar "osmode" 0)
(setvar "celtype" "16-os cso")
;; use vla-catch-all-apply to avoid exiting code if user cancels
(vl-catch-all-apply
'(lambda (/ pt lst)
;; get points form user
(while (setq pt (getpoint "\nPick point: "))
(setq lst (cons pt lst))
)
(if (< 2 (length lst))
(progn
;; create the polyline
(command "_pline")
(foreach p (reverse lst)
(command p)
)
(command "")
)
)
)
)
;; restore the previous system variables values
(setvar "osmode" osmode)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(princ)
)
- 最简单的方法就是 运行 命令
PLINE
并等待用户结束。
- 颜色可以通过系统变量改变
CECOLOR
.
通过系统变量恢复默认你可以使用错误捕获(当用户点击 Esc ),当用户以 [enter]
[space]
结束时你将通过调用 (*error*)
函数
恢复默认值
(defun c:nyomvodal (/ osmode clayer celtype
*error* ) (defun *error* ( msg / )
(if (not (null msg ) ) (progn (princ "\nname:*error*: " ) (princ msg ) (princ "\n") ) )
(setvar "osmode" osmode)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(setvar 'CECOLOR cecolor)
)
;; save the current osmode, clayer and celtype
(setq osmode (getvar "osmode"))
(setq clayer (getvar "clayer"))
(setq celtype (getvar "celtype"))
(setq cecolor (getvar "CECOLOR"))
;; create a new layer and make it current
(command "_layer" "_make" "nyomvodal" "_color" 3 "nyomvodal" "")
;; set the current osmode and line type
(setvar "osmode" 0)
(setvar "CECOLOR" "1")
;(setvar "celtype" "16-os cso")
(command "_pline" pause)
(*error* nil) ; to restore default color, layer ...
(princ)
)
我有这个 AutoLisp 代码,我想问 2 个问题:
1.如何在绘制过程中(或选择点时)使多段线可见?
2。我怎样才能改变折线的颜色而不是层的颜色?
如果我得到答案,非常感谢。
(defun c:nyomvodal (/ osmode clayer celtype)
;; save the current osmode, clayer and celtype
(setq osmode (getvar "osmode"))
(setq clayer (getvar "clayer"))
(setq celtype (getvar "celtype"))
;; create a new layer and make it current
(command "_layer" "_make" "nyomvodal" "_color" 3 "nyomvodal" "")
;; set the current osmode and line type
(setvar "osmode" 0)
(setvar "celtype" "16-os cso")
;; use vla-catch-all-apply to avoid exiting code if user cancels
(vl-catch-all-apply
'(lambda (/ pt lst)
;; get points form user
(while (setq pt (getpoint "\nPick point: "))
(setq lst (cons pt lst))
)
(if (< 2 (length lst))
(progn
;; create the polyline
(command "_pline")
(foreach p (reverse lst)
(command p)
)
(command "")
)
)
)
)
;; restore the previous system variables values
(setvar "osmode" osmode)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(princ)
)
- 最简单的方法就是 运行 命令
PLINE
并等待用户结束。 - 颜色可以通过系统变量改变
CECOLOR
.
通过系统变量恢复默认你可以使用错误捕获(当用户点击 Esc ),当用户以 [enter]
[space]
结束时你将通过调用 (*error*)
函数
(defun c:nyomvodal (/ osmode clayer celtype
*error* ) (defun *error* ( msg / )
(if (not (null msg ) ) (progn (princ "\nname:*error*: " ) (princ msg ) (princ "\n") ) )
(setvar "osmode" osmode)
(setvar "clayer" clayer)
(setvar "celtype" celtype)
(setvar 'CECOLOR cecolor)
)
;; save the current osmode, clayer and celtype
(setq osmode (getvar "osmode"))
(setq clayer (getvar "clayer"))
(setq celtype (getvar "celtype"))
(setq cecolor (getvar "CECOLOR"))
;; create a new layer and make it current
(command "_layer" "_make" "nyomvodal" "_color" 3 "nyomvodal" "")
;; set the current osmode and line type
(setvar "osmode" 0)
(setvar "CECOLOR" "1")
;(setvar "celtype" "16-os cso")
(command "_pline" pause)
(*error* nil) ; to restore default color, layer ...
(princ)
)