(setq mai_cehui_gcd_dianhao (list "ZDH" "1")) ;测绘点号所在图层及颜色
(setq mai_cehui_gcd_bianma (list "ZBM" "3"))  ;测绘点文字所在图层及颜色
(setq mai_cehui_gcd_blk (list "GCD" "1"))     ;测绘高程块所在图层及颜色
(setq mai_cehui_style (list "正等线体" 3))    ;测绘文字所在字形及字高
(setq mai_cehui_tin (list "SJW" "3"))         ;三角网所在图层及颜色
(setq mai_cehui_dgx (list "DGX" "2"))         ;等高线所在图层及颜色
(setq mai_draw_units 0.001) ;强行将绘图单位改为米
(mai_get_scale)
(or mai_cehui_gc_blkname (setq mai_cehui_gc_blkname "GC200"))

;[功能] pline,lwpline点坐标表
(defun mai_get_face_points ( e / i v lst)
	(if (= (mai_dxf 0 (setq lst (entget e))) "3DFACE")
		(mai_remove_same (list (mai_dxf 10 lst)(mai_dxf 11 lst)(mai_dxf 12 lst)(mai_dxf 13 lst)))
		(progn
			(setq i 0)
			(while (setq v (vlax-curve-getpointatparam e (setq i (1+ i))))
				(setq lst (cons v lst))
			)
			(reverse lst)
		)
	)
)

(defun mai_tri_zhongxin (p1 p2 p3)
	(inters p3 (mai_divide_point p1 p2 0.5) p1 (mai_divide_point p3 p2 0.5))
)



;;;创建 Cass 高程点 (gxl_cs:gcd 插入点 高程 图块比例 小数位数 图层)
;(setq inspt (getpoint)) (setq scale 0.5) (setq height "AAAA")(setq height 12.25)
;(setq inspt (getpoint)) (setq scale 0.5) (setq height "AAAA")(setq height 12.25)
; (mapcar 'set '(inspt height scale xsws la) (list pt (caddr pt) mai_scale2 2 (car mai_cehui_gcd_blk)))
; (mapcar 'set '(inspt height scale xsws la) (list (list 3.29603e+06 540843.0 19.34) 19.34 0.05 2 "GCD"))
(defun gxl_cs:gcd (inspt height scale xsws la / pt blkdef )
	(setq height (if height (rtos height 2 xsws) ""))
	(regapp "SOUTH")
	(setq blockname mai_cehui_gc_blkname)
	(if la
		(or (tblsearch "layer" la)
			(mai_create_layer la (cadr mai_cehui_gcd_blk))
		)
		(apply 'mai_create_layer mai_cehui_gcd_blk)
	)
	; (setq mai_cehui_style (list "正等线体" 3))    ;测绘文字所在字形及字高
	; (setq maiDefaultfonts (list "TXT1.SHX" "TXT2.SHX" "HZDX.SHX" "HZHT.SHX" "宋体") rewrite T)
	(mai_create_style (car mai_cehui_style) (car maiDefaultfonts) (caddr maiDefaultfonts) 0.8)

	;;;检查是否存在高程点图块定义
	(or (tblobjname "block" blockname)
		(progn
			;创建块
			;;;==========
			;;;做块头
			(entmake
				(list
					'(0 . "BLOCK") '(100 . "AcDbEntity") '(100 . "AcDbBlockBegin")
					(cons 2 blockname) '(70 . 2) '(10 0 0 0)
				)
			)
			(entmake
				(list
					'(0 . "HATCH")
					'(100 . "AcDbEntity")
					'(100 . "AcDbHatch")
					'(10 0.0 0.0 0.0)
					'(210 0.0 0.0 1.0)
					'(2 . "SOLID")
					'(8 . "0")
					'(62 . 256) '(70 . 1) '(71 . 0) '(91 . 1)    '(92 . 7) '(72 . 1)
					'(73 . 1)    '(93 . 2) '(10 -0.4 0.0 0.0) '(42 . 1.0) '(10 0.4 0.0 0.0)
					'(42 . 1.0) '(97 . 0) '(75 . 0) '(76 . 1)    '(47 . 0.0) '(98 . 1)
					'(10 0.0 0.0 0.0)
				)
			)
			;;;做块尾
			(entmake (list '(0 . "ENDBLK") '(100 . "AcDbEntity") '(100 . "AcDbBlockEnd")))
		)
	)
	;;;插入块
	; (setq att (car (mai_get_blk_atts (car(entsel)) nil)))
	(setq blk (mai_insert_entmake blockname inspt scale scale scale 0))
	(if (setq att (car (mai_get_blk_atts blk nil)))
		; (setq att (car (mai_get_blk_atts (car(entsel)) nil)))
		(progn
			(setq
				elst (entget (car att))
				elst (subst (cons 8 la) (assoc 8 elst) elst)
				elst (subst (cons 1 height) (assoc 1 elst) elst)
				elst (subst (cons 7 (car mai_cehui_style)) (assoc 7 elst) elst)
				elst (subst (cons 10 (mapcar '+ inspt (list (* scale 0.5 (cadr mai_cehui_style)) 0 0))) (assoc 10 elst) elst)
				elst (subst (cons 40 (* scale (cadr mai_cehui_style))) (assoc 40 elst) elst)
				elst (subst (cons 66 1) (assoc 66 elst) elst)
				elst (vl-remove-if '(lambda(X)(= (car x) 62)) elst)
			)
			(entmod elst)
			(entupd (car att))
		)
		(progn
			(entdel (entlast))
			(entmake
				(list
					'(0 . "INSERT")
					'(100 . "AcDbEntity")
					'(100 . "AcDbBlockReference")
					'(66 . 1)
					;;;属性跟随标志,1跟随，0不跟随
					(cons 2 blockname)
					(cons 8 la)
					(cons 10 inspt)
					(cons 41 scale)
					(cons 42 scale)
					(cons 43 scale)
					(list -3 '("SOUTH" (1000 . "202101")))
				)
			)
			;;;插入属性
			(entmake
				(list
					'(0 . "ATTRIB")
					'(100 . "AcDbEntity")
					'(100 . "AcDbText")
					(cons 8 la)
					(cons 10 (setq pt (polar inspt 0 (* mai_scale2 0.5 (cadr mai_cehui_style)))))
					; (cons 40 (* 2.0 scale))
					(cons 40 (* mai_scale2 (cadr mai_cehui_style)))
					(cons 50 0)
					(cons 41 0.8)
					(cons 51 0)
					(cons 1 height)
					(cons 7 (car mai_cehui_style))
					(cons 72 0)
					(cons 11 pt)
					'(100 . "AcDbAttribute")
					(cons 2 "height")
					(cons 70 0)
					(cons 74 2)
				)
			)
			;;;结束标志
			(entmake '((0 . "SEQEND")))
		)
	)
	(princ)
)
