;
;   联系人:   sena
;   QQ    :   272116623
;   Email :   ws.cn@163.com
;   网址  :   www.hgcad.com
;;******************************************************************************************
;
;用户自定义命令

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(1)、根据版本,设置快捷键CO的copy命令，即设置AutoCAD2004及以前版本默认为多重COPY

(if (<= (atof (getvar "acadver")) 16.0) 
    (defun C:CO ()
           (command "copy" (ssget) "" "m")
    )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(2)、定义数字命令(0-9),根据color切换layer,然后运行line,dimlinear,text,  此处的layer请务必与
;     初使化(CSH)命令里面配置相符,使用数字命令前请先确定相应层已被创建

(defun HGCADLINE( CLAYER / p0 )  
	  (setvar "CLAYER" CLAYER)
	  (setvar "cecolor" "bylayer")
	  (setvar "celtype" "bylayer")
	  (setvar "CELWEIGHT" -1)
  	  (setq p0 (getpoint "\n指定一点或 [右键退出]:"))
	  (if (/= p0 nil)(vl-cmdf "line" p0))
)

(defun C:0() (HGCADLINE "0"))
(defun C:1() (HGCADLINE "中心线"))
(defun C:2() (HGCADLINE "粗实线"))
(defun C:3() (HGCADLINE "双点划线"))
(defun C:4() (HGCADLINE "中粗线"))
(defun C:5() (HGCADLINE "0"))
(defun C:6() (HGCADLINE "虚线"))
(defun C:7() (HGCADLINE "细实线"))
(defun C:8( / p0)
  	     (setvar "CLAYER" "标注")
	     (setvar "cecolor" "bylayer")
	     (setvar "celtype" "bylayer")
	     (setvar "CELWEIGHT" -1)
	     (setq p0 (getpoint "\n指定一点或 [右键退出]:"))
	     (if (/= p0 nil)(command "dimlinear" p0))
)
(defun C:9( / p0)
  	     (setvar "CLAYER" "文本")
	     (setvar "cecolor" "bylayer")
	     (setvar "celtype" "bylayer")
	     (setvar "CELWEIGHT" -1)
	     (setq p0 (getpoint "\n指定一点或 [右键退出]:"))
  	     (if (/= p0 nil)(progn
  	     	(IF (> (CDR (ASSOC 40 (TBLSEARCH "STYLE" (GETvar "TEXTSTYLE")))) 0.0)
		 	(command "text" p0 "0" "　" "DDEDIT" (entlast) "")
		 	(command "text" p0 (* (getvar "dimscale") 5) "0" "　" "DDEDIT" (entlast) "")
	     	)
	     	(if (= (cdr (assoc 1 (entget (entlast)))) "　")(vl-cmdf "erase" (entlast) ""))
	     ))
  	     (princ)
)

(defun ChpropEx (la)
	(command "chprop" (ssget) "" "LA" la "c" "bylayer" "lt" "bylayer" "lw" "bylayer" "")
	(princ)
)

(defun C:00() (ChpropEx "0"))
(defun C:11() (ChpropEx "中心线"))
(defun C:22() (ChpropEx "粗实线"))
(defun C:33() (ChpropEx "双点划线"))
(defun C:44() (ChpropEx "中粗线"))
(defun C:55() (ChpropEx "0"))
(defun C:66() (ChpropEx "虚线"))
(defun C:77() (ChpropEx "细实线"))
(defun C:88() (ChpropEx "标注"))
(defun C:99() (ChpropEx "文本"))
 