三不五時收到2D CAD檔案時,就會有下列狀況發生:

明明是簡單的2D圖面,確有些線條或圓...等物件,不在XY平面上!

有時平面看到兩線相交,但就是抓不到『交點』~~

這就需要檢查物件的『Z』值了,將其『Z』值改為『0』才行處理,

但若圖面有很多很多物件都有類似的情況的話~~ 真的會『欲哭無淚』!

這時你會罵該圖之前的繪圖者了~~(PS.心理罵就好,留些口德。)

所以面對很多物件要修正時...就要用最笨的方式給他做下去嗎?當然不是囉!

反正就給PC去處理這種繁瑣的重複的工作囉!

自己寫程式~~想破頭!

先去網路上找有沒有現成可用的程式吧!!

以下是我找到的,還不錯用喔!!

;;-----------以下是LISP程式-----------------------------------------------------------------------------

(defun C:zzz (/ ss count ename i startpoint endpoint ent)
  (princ "\n selected object's Z=>>>0 \n")
  (setq ss (ssget))
  (princ "Working......\n")
  (setvar "Cmdecho" 0)
  (command "_.undo" "begin")
  (setq count (sslength ss))
  (setq i 0)
  (while (< i count)
    (setq ename (ssname ss i))
    (setq ent (entget ename))
    (setq enttype (cdr (assoc 0 ent)))
    (if (= enttype "LINE")
      (progn (setq startpoint (cdr (assoc 10 ent)))
      (setq endpoint (cdr (assoc 11 ent)))
      (setq startpoint (trans startpoint 0 1))
      (setq endpoint (trans endpoint 0 1))
      (setq startpoint
      (list (car startpoint)
     (cadr startpoint)
     0
      )
      )
      (setq endpoint (list (car endpoint) (cadr endpoint) 0))
      (setq startpoint (trans startpoint 1 0))
      (setq endpoint (trans endpoint 1 0))
      (setq ent (subst (cons 10 startpoint) (assoc 10 ent) ent))
      (setq ent (subst (cons 11 endpoint) (assoc 11 ent) ent))
      (entmod ent)
      )
    )
    (setq i (1+ i))
  )
  (command "_.change" ss "" "P" "elev" 0 "thickness" 0 "")
  (command "_.undo" "end")
  (setvar "cmdecho" 1)
  (princ "\n Z=>>>0 done \n")
  (princ)
)

;;------------------以上是LISP程式----------------------------------------------------------------------

載用後,鍵入ZZZ 就可以執行了~~

創作者介紹

月蜻蜓的天空

willie23 發表在 痞客邦 PIXNET 留言(0) 人氣()