[源码] 炸開圖塊修改,然後再依原圖塊存檔的小程序
(defun C:xb1 (/ ss bss en1 EN1_data)(if (= xb_name nil)
(progn
(command "ucs" "w")
(setq bss (entsel))
(command "_.undo" "_group")
(setq eN1 (car bss))
(setq EN1_data (entget EN1))
(setq xb_name (cdr (assoc 2 EN1_data))) ;名稱
(setq xb_pt (cdr (assoc 10 EN1_data)))
;;插入點
(setq ttx (polar xb_pt 0 100))
(setq tty (polar xb_pt (/ pi 2) 100))
(SETQ mir_41 (assoc 41 EN1_data))
(SETQ mir_42 (assoc 42 EN1_data))
(setq xb_layer (cdr (assoc 8 EN1_data)))
;;圖層
(setq xb_rot (cdr (assoc 50 EN1_data)))
;;旋轉
(setq xb_dg1 (* (/ xb_rot pi) 180))
(setq xb_sc (cdr (assoc 41 EN1_data)))
;;以下為X向鏡射
(if (< (cdr (assoc 41 EN1_data)) 0)
(progn
(setq mi_x "1")
)
)
;;以下為y向鏡射
(if (< (cdr (assoc 42 EN1_data)) 0)
(progn
(setq mi_y "1")
)
)
;;;將xb_sc轉為正數
(if (= mi_x "1")
(setq xb_sc (abs xb_sc))
)
;;比例
(setq sc_re (/ 1 xb_sc))
;;有旋轉及縮放的處理差異
(if (and (= xb_rot 0) (= xb_sc 1))
(progn
(COMMAND "EXPLODE" bss "")
(setq ss (ssget "_p"))
(SETVAR "QAFLAGS" 1)
(COMMAND "GROUP" SS "")
(SETQ ENLAST1 (ENTLAST))
(SETVAR "QAFLAGS" 0)
(command "pickstyle" "0")
(command "ucs" "p")
)
(progn
(COMMAND "EXPLODE" bss "")
(setq ss (ssget "_p"))
(SETVAR "QAFLAGS" 1)
(COMMAND "GROUP" SS "")
(SETQ ENLAST1 (ENTLAST))
(SETVAR "QAFLAGS" 0)
(command "pickstyle" "0")
(command "ucs" "p")
)
)
)
(princ "前次編輯未結束")
)
(command "_.undo" "_end")
)
(defun C:cb1 (/ HOLDECHO HOLDBLIP A AA BLKREF pt)
(setvar "CMDECHO" 0)
(command "ucs" "w")
(setq olayer (getvar "clayer"))
(setvar "clayer" xb_layer)
(command "pickstyle" "1")
(redraw ENLAST1 3)
(setq AA (ssget))
(command "_.undo" "_group")
(setq HOLDECHO (getvar "cmdecho"))
(setq HOLDBLIP (getvar "blipmode"))
(setq HOLDOSMODE (getvar "OSMODE"))
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setvar "OSMODE" 0)
(setq A (rtos (* (getvar "CDATE") 1E8)))
(command "scale" aa "" xb_pt sc_re)
;;縮回1
(command "rotate" aa "" xb_pt (- 0 xb_dg1))
;;轉回0
(if (= mi_x "1")
(command "mirror" aa "" xb_pt tty "y"))
(if (= mi_y "1")
(command "mirror" aa "" xb_pt ttx "y"))
;;鏡射回去
(if (/= AA NIL)
(progn
(command "-BLOCK" xb_name "y" xb_pt AA "")
(command "-INSERT" xb_name xb_pt "" "" "" "" "")
(SETQ ENLAST1 (ENTLAST))
(setq enL1_data (entget ENLAST1))
(command "scale" ENLAST1 "" xb_pt xb_sc)
(setq oldr (assoc 41 enL1_data))
(setq enL1_data (subst mir_41 oldr enL1_data))
(entmod enL1_data)
(setq oldr (assoc 42 enL1_data))
(setq enL1_data (subst mir_42 oldr enL1_data))
(entmod enL1_data)
(command "rotate" ENLAST1 "" xb_pt xb_dg1)
(command "attsync" "" ENLAST1 "")
;;放置最下方
(command "draworder" ENLAST1 "" "b")
(command "hatchtoback")
)
)
(if (/= AA NIL)
(setq xb_name nil)
)
(setvar "blipmode" HOLDBLIP)
(setvar "cmdecho" HOLDECHO)
(setvar "OSMODE" HOLDOSMODE)
(setvar "clayer" olayer)
(command "_.undo" "_end")
(command "ucs" "p")
(setq mi_x "0" mi_y "0")
(princ)
)
(defun C:xx1 ()
(setq xb_name nil)
(princ "Xb1指令重置")
)
页:
[1]