[LISP函数-点集]: 给点表,绘制PLINE
;|
给点表,绘制PLINE,封闭
|;
(defun $XDLSP_Draw_Pline (pts tf)
;(xdrx_sysVar_push "osmode")
(setvar "osmode" 0)
(apply
'command
(cons "pline" pts)
)
(if tf
(command "c")
(command "")
)
;(xdrx_sysVar_pop)
)
(defun xd-mkpline (pts tf)
(entmake
(append
'((0 . "lwpolyline") (100 . "AcDbEntity") (100 . "AcDbPolyline"))
(list (cons 90 (length pts)))
(list (cons 70
(if tf
1
0
)
)
)
(mapcar '(lambda (x) (cons 10 (list (car x) (cadr x)))) pts)
)
)
) 这是个简单的
只是把线画出来
不如ea的可以指定图层什么的
(defun pts2PL ( pts)
(vl-cmdf "pline")
;;(mapcar '(lambda (x) (vl-cmdf x)) pts)
(mapcar 'vl-cmdf pts)
;;如果下面最后这样 就多一个顶点
;;(vl-cmdf (car pts) "")
;;下面这样闭合
(vl-cmdf "c")
)
;;;http://www.theswamp.org/index.php?topic=20575.0
;;Expects pts to be a list of 2D or 3D points
;;Returns the ename of the new pline object
(defun makePline (pts ; list of points
closed ; 1 for closed 0 overwise
layer ; if new layer entmake will create it
;;must be a valid layer name
/ zdir elv)
;; catch nil layer name - CAB added
(or layer (setq layer (getvar "CLAYER")))
(setq zdir (trans '(0 0 1) 1 0 t)
elv(caddr (trans (car pts) 1 zdir))
)
(entmakex ; CAB added x
(append
(list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
(cons 8 layer) ; CAB added
(cons 90 (length pts))
(cons 70 closed) ; 1 for closed 0 overwise
(cons 38 elv)
(cons 210 zdir)
)
(mapcar '(lambda (pt) (cons 10 (trans pt 1 zdir))) pts)
)
)
)
学习一下,我想用pline画个东西,一天没实现,很失败。 大有用处,谢谢楼主 找了很久,很开心
不错,很好的代码。 小白,看不太懂。简要说一下具体功能就好了
页:
[1]