📄 delete_hatch.lsp
字号:
;************defun change_prop start*******
(defun change_prop (sel layer color line /)
;(setq sel_ent (ssget "p"))
(if sel
(progn
(if (/= layer "")
(command "change" sel "" "p" "la" layer "")
)
(if (/= color "")
(command "change" sel "" "p" "c" color "" )
)
(if (/= line "")
(command "change" sel "" "p" "lt" line "")
)
)
)
)
(defun mxb_head ()
(command "ucs" "w")
(setq old_epmxb (ssget "X" '((0 . "INSERT") (2 . "epid_head"))))
(if (= nil old_epmxb)
(progn
(setq mxb_cso (getpoint "选取明细表的位置:"))
(command "insert" "epid_head.dwg" mxb_cso "" "" "")
(command "ucs" "o" mxb_cso)
(setq mxb_x1 (car mxb_cso))
(setq mxb_y1 (car (cdr mxb_cso)))
)
(if (= 1
(sslength old_epmxb)
)
(progn
(print "!!!图形中已 明细表")
(setq temp_cso (assoc '10 (entget (ssname old_epmxb 0))))
(setq mxb_x1 (car (cdr temp_cso)))
(setq mxb_y1 (cadr (cdr temp_cso)))
;(command "ucs" "o" (list mxb_x1 mxb_y1))
)
(princ "!!!图形中已有多基准坐标系!!!")
)
)
)
(defun cso_tran (/ cso)
(command "ucs" "W")
(setq old_cso (ssget "X" '((0 . "INSERT") (2 . "cso"))))
(if (= nil old_cso)
(progn
(setq cso (getpoint "选取基准点"))
(command "insert" "cso.dwg" cso "" "" "")
(command "ucs" "o" cso)
(setq x1 (car cso))
(setq y1 (car (cdr cso)))
)
(if (= 1
(sslength old_cso)
)
(progn
(print "!!!图形中已有基准坐标系!!!")
(setq temp_cso (assoc '10 (entget (ssname old_cso 0))))
(setq x1 (car (cdr temp_cso)))
(setq y1 (cadr (cdr temp_cso)))
(command "ucs" "o" (list x1 y1))
)
(princ "!!!图形中已有多基准坐标系!!!")
)
)
)
;*************Find ejector /pin/sleeves Flat EJECTOR
(defun find_ej (ej_sel / ej_sel e_tb ej_size_tb dia ej_temp)
;find ejector
(setq sel_ejold
(ssget "x" '((0 . "INSERT") (2 . "EPIN")))
)
(if sel_ejold
(command "erase" sel_ejold "")
)
;(setq ej_sel
;(ssget "X" '((8 . "ej_old") (0 . "CIRCLE")))
;)
;(if ej_sel
; (progn
;(if (not (tblsearch "layer" "ej_old"))
;(command "_.layer" "_new" "ej_old" "_color"
; "4" "ej_old" "_ltype" "continuous"
; "mxb" ""
; )
;(command "_.layer" "thaw" "ej_old" "on" "mxb" "unlock" "mxb" "")
;)
;(change_prop ej_sel "ej_old" "" "")
(setq os_old (getvar "osmode"))
(setvar "osmode" 0)
(command "ucs" "")
(setq ej_tb nil)
(setq ej_size_tb nil)
(setq type_num 0)
(setq dia_num 0)
(repeat (sslength ej_sel)
(setq ej_temp nil)
(setq dia nil
cenpt nil
)
(setq ej_temp
(entget (ssname ej_sel type_num))
)
(setq dia (* 2 (cdr (assoc '40 ej_temp))))
(setq cenpt (cdr (assoc '10 ej_temp)))
(if (not (member dia ej_size_tb))
(progn
(setq ej_size_tb
(cons dia ej_size_tb)
)
(setq dia_num (+ 1 dia_num))
)
)
(setq ej_tb
(cons (cons dia cenpt) ej_tb)
)
(setq type_num (+ 1 type_num))
)
(setq ej_size_tb_ nil)
(setq num_ 0)
(foreach dia_ ej_size_tb
(setq n 0)
(foreach dia_value ej_size_tb
(if (> dia_ dia_value)
(setq n (+ 1 n))
)
)
(setq ej_size_tb_
(cons
(list n dia_)
ej_size_tb_
)
)
)
;;;;;;;;;;;;;REDEFINE SORT
(setq n 0)
(setq ej_tb_ nil)
(repeat (- dia_num 1)
(setq dia_value (* 2 (car (cdr (assoc n ej_size_tb_))))) ;ok
(setq n1 0)
(setq ej_pos_tb nil)
(setq ej_pos_ nil)
(repeat (- type_num 1) ;ok
(if (= dia_value (car (nth n1 ej_tb)))
(progn
;(print dia_value)
;(print (car (nth n1 ej_tb)))
;(print "sfdf")
(setq ej_pos_
(cons (cdr (nth n1 ej_tb))
ej_pos_
)
)
)
)
(setq n1 (+ 1 n1))
)
(setq ej_pos_tb (list dia_value ej_pos_))
(setq ej_size_pos_tb
(cons
ej_pos_tb
ej_size_pos_tb
)
)
(setq n (+ 1 n))
)
;(print ej_size_pos_tb)
(setq dd ej_size_pos_tb)
(setq epid 0)
(foreach ej_data_temp ej_tb
(setq ej_dia_temp (car ej_data_temp)
ej_center_temp (cdr ej_data_temp)
)
;(print "!!!\n")
;(print ej_dia_temp)
;(print ej_center_temp)
(if (not (tblsearch "layer" "ejpin"))
(command "_.layer" "_new" "ejpin" "_color"
"4" "ejpin" "_ltype" "continuous"
"ejpin" "set" "ejpin" ""
)
(command "_.layer" "thaw" "ejpin" "on"
"ejpin" "unlock" "ejpin" "set"
"ejpin" ""
)
)
;(change_prop ej_sel "ej_old" "" "")
(command "insert" "EPIN.dwg" ej_center_temp
ej_dia_temp "" ""
)
)
(setvar "osmode" os_old)
; )
;)
;(setq ej_total_tb (list ej_size_tb_ ej_size_pos_tb ))
)
;find sleeves ejector
(defun find_es_pin (/)
;es_sel es_tb es_size_tb dia cenpt es_temp n n1)
(setq sel_pinold
(ssget "x" '((0 . "INSERT") (2 . "PIN")))
)
(if sel_pinold
(command "erase" sel_pinold "")
)
(setq sel_esold
(ssget "x" '((0 . "INSERT") (2 . "ES*")))
)
(if sel_esold
(command "erase" sel_esold "")
)
;(setq es_sel
; (ssget "X" '((8 . "ej_old") (0 . "ARC")))
;)
(if es_sel
(progn
(setq os_old (getvar "osmode")) ;(change_prop es_sel "ej_old" "" "")
(setvar "osmode" 0)
(command "ucs" "")
(setq es_tb nil)
(setq es_size_tb nil)
(setq es_cenpt_tb nil)
(setq cir_tb nil)
(setq type_num 0)
(setq point_num 0)
;*******GEt ES_cenpt_tb**************
(repeat (sslength es_sel)
(setq es_temp nil)
(setq dia nil
cenpt nil
)
(setq es_temp
(entget (ssname es_sel type_num))
)
(setq arc_start (cdr (assoc '50 es_temp)))
(setq arc_end (cdr (assoc '51 es_temp)))
(if (= "3.14159" (rtos (abs (- arc_start arc_end)) 2 5))
(progn
(setq dia (* 2 (cdr (assoc '40 es_temp))))
(setq cenpt (cdr (assoc '10 es_temp)))
(if (not (member cenpt es_cenpt_tb))
(progn
(setq es_cenpt_tb ;get cenpt_point
(cons cenpt es_cenpt_tb)
)
(setq point_num (+ 1 point_num))
)
)
(setq cir_tb ;get all half circle data
(cons (cons dia cenpt) cir_tb)
)
)
)
(setq type_num (+ 1 type_num)) ;round es_sel data
)
;**************************************
(setq es_size_tb nil
es_total_tb nil
pin_total_tb nil
pin_dia_tb nil
)
(setq n 0)
(while (< n point_num)
(setq cir_point (nth n es_cenpt_tb))
;GEt point from center position table
(setq n1 0)
(setq _num 0)
(setq cir_dia_tb nil)
;(princ "sfskfl\n\n")
(while (< n1 type_num )
(setq cir_data (nth n1 cir_tb)) ;search data in same postion
;(princ cir_data)
(setq n1 (+ 1 n1))
;(princ "XXX")
(setq _cenpt (cdr cir_data))
(setq cir_dia nil)
;Get single point data
(if (and (= (car _cenpt) (car cir_point))
(= (car (cdr _cenpt)) (car (cdr cir_point)))
) ;Check point X value and Y value from center position table
(progn
(setq cir_dia (car cir_data))
;(princ cir_dia)
;(princ _cenpt)
;(princ "number ***\n")
;(princ "\n")
(if (not (member cir_dia cir_dia_tb)) ;
(progn
;(princ "Find es_cir\n")
(setq cir_dia_tb (cons cir_dia cir_dia_tb))
(setq _num (+ 1 _num)) ;get number of same point
)
) ;add cir_dia end
)
;(progn
;(princ "afsdf\n")
;)
)
) ;search same postion end
(setq n (+ 1 n))
;add sleeves_type to es_size_tb and add sleeves_data to add
(if (= _num 2)
(progn
(setq d1 nil
d2 nil
)
(setq d1 (nth 0 cir_dia_tb)
d2 (nth 1 cir_dia_tb)
)
(if (< d1 d2)
(progn
(setq cir_dia_tb (cons d2 d1))
)
)
(if (not (member cir_dia_tb es_size_tb))
(setq es_size_tb (cons cir_dia_tb es_size_tb))
;Add sleeve_type to es_size_tb
)
(setq es_total_tb
(cons (list cir_dia_tb cir_point) es_total_tb)
)
)
)
(if (= 1 _num)
(progn
;(alert "Find one circle in same postion only")
(setq pin_dia (car cir_dia_tb))
(if (not (member pin_dia pin_dia_tb))
(setq pin_dia_tb (cons pin_dia pin_dia_tb))
;Add sleeve_type to es_size_tb
)
(setq pin_total_tb
(cons (cons pin_dia cir_point) pin_total_tb)
)
)
(if (< _num 2)
(progn
(alert "Find more than two circle in same postion ")
)
)
)
)
(if (and es_total_tb es_size_tb)
(progn
(setq es_tb (cons es_size_tb es_total_tb))
(foreach es_data_temp es_total_tb
(setq es_od_temp (car (car ES_data_temp)))
(setq es_id_temp (cdr (car ES_data_temp)))
(if (listp es_id_temp)
(setq es_id_temp (car es_id_temp))
)
(setq es_pos_temp (car (cdr es_data_temp)))
(if (not (tblsearch "layer" "espin"))
(command "_.layer" "_new" "espin" "_color"
"6" "espin" "_ltype" "continuous"
"espin" "set" "espin" ""
)
(command "_.layer" "thaw" "espin" "on"
"espin" "unlock" "espin" "set"
"espin" ""
)
)
;(change_prop ej_sel "ej_old" "" "")
(command "insert" "ES.dwg" es_pos_temp es_od_temp es_od_temp 0 )
(setq dd (command "insert" "ESPIN.dwg" es_pos_temp es_id_temp es_id_temp 0))
)
)
)
(if (and pin_total_tb pin_dia_tb)
(progn
(setq pin_tb (cons pin_dia_tb pin_total_tb))
(foreach pin_data_temp pin_total_tb
(setq pin_dia_temp (car pin_data_temp))
(setq pin_pos_temp (cdr pin_data_temp))
(if (not (tblsearch "layer" "pin"))
(command "_.layer" "_new" "pin" "_color"
"3" "pin" "_ltype" "continuous"
"pin" "set" "pin" ""
)
(command "_.layer" "thaw" "pin" "on"
"pin" "unlock" "pin" "set" "pin"
""
)
)
;(change_prop ej_sel "ej_old" "" "")
(command "insert" "PIN.dwg" pin_pos_temp pin_dia_temp "" "")
(setq epid (+ 1 epid))
)
)
)
(setvar "osmode" os_old)
)
;(princ "hav't sleeve in drawing!")
)
)
(defun insert_id (/)
(setq sel_ej
(ssget "x" '((0 . "INSERT") (2 . "EPIN")))
)
(setq sel_pin
(ssget "x" '((0 . "INSERT") (2 . "PIN")))
)
(setq sel_es
(ssget "x" '((0 . "INSERT") (2 . "ES")))
)
(setq sel_espin
(ssget "x" '((0 . "INSERT") (2 . "ESPIN")))
)
(setq sel_id
(ssget "x" '((0 . "INSERT") (2 . "ep_pos")))
)
(setq sel_idtext
(ssget "x" '((0 . "TEXT") (8 . "mxb") (7 . "lxy2")))
)
(if (or (and sel_es sel_espin) sel_pin sel_ej)
(progn
(if sel_id
(command "erase" sel_id "")
)
(if sel_idtext
(command "erase" sel_idtext "")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -