将选择的对象投影到指定的参考框中
;;;;;;;;;;;将选择的对象投影到指定的参考框中(defun c:sxx (/ *error* des ent enx idx lst mat ocs sel src typ)
;; 错误处理函数
(defun *error* (msg)
(LM:endundo (LM:acdoc))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
;; 开始事务
(LM:startundo (LM:acdoc))
;; 主程序
(if
(and
;; 选择对象
(setq sel
(LM:ssget "\n请选择对象: "
'("_:L"
((-4 . "<OR")
(-4 . "<AND")
(0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,POINT")
(-4 . "<NOT")
(-4 . "<AND")
(0 . "POLYLINE") (-4 . "&") (70 . 88)
(-4 . "AND>")
(-4 . "NOT>")
(-4 . "AND>")
(-4 . "<AND")
(0 . "SPLINE") (-4 . "&=") (70 . 8)
(-4 . "AND>")
(-4 . "OR>")
)
)
)
)
;; 获取源参考框
(setq src (2dprojection:getreferenceframe "\n请选择源对象的参考框: "))
;; 获取目标参考框
(setq des (2dprojection:getreferenceframe "\n请选择投影的参考框: "))
;; 获取变换矩阵
(setq mat (2dprojection:getmatrix src des))
;; 获取当前 UCS 的 Z 轴方向
(setq ocs (trans '(0.0 0.0 1.0) 1 0 t))
)
;; 遍历选择集
(repeat (setq idx (sslength sel))
(setq ent (ssname sel (setq idx (1- idx)))
enx (entget ent)
typ (cdr (assoc 0 enx))
)
(cond
;; 处理点对象
((= "POINT" typ)
(entmake
(vl-list*
'(0 . "POINT")
(cons 10 (trans (2dprojection:mappoint mat (trans (cdr (assoc 10 enx)) 0 ocs)) ocs 0))
(LM:defaultprops enx)
)
)
)
;; 处理直线对象
((= "LINE" typ)
(entmake
(vl-list*
'(0 . "LINE")
(cons 10 (trans (2dprojection:mappoint mat (trans (cdr (assoc 10 enx)) 0 ocs)) ocs 0))
(cons 11 (trans (2dprojection:mappoint mat (trans (cdr (assoc 11 enx)) 0 ocs)) ocs 0))
(LM:defaultprops enx)
)
)
)
;; 处理多段线、圆弧、圆、椭圆等对象
((setq lst (LM:Entity->PointList ent))
(entmake
(append
(list
'(000 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
(cons 90 (length lst))
(if (vlax-curve-isclosed ent) '(70 . 1) '(70 . 0))
)
(LM:defaultprops enx)
(mapcar '(lambda (p) (cons 10 (2dprojection:mappoint mat (trans p 0 ent)))) lst)
(list (assoc 210 enx))
)
)
)
)
)
)
;; 结束事务
(LM:endundo (LM:acdoc))
(princ)
)
将选择的对象投影到指定的参考框中,可以试下!
缺函数,Error: no function definition: 2DPROJECTION:GETREFERENCEFRAME 小毛草发出好多代码
页:
[1]