- 积分
- 3897
- 明经币
- 个
- 注册时间
- 2022-9-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
(vl-acad-defun (defun C:ZD() (vl-load-com) (regapp "SOUTH") (regapp "NAME") (regapp "CODE") (regapp "TIME") (setq time (list "TIME" (cons 1000 (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD-HH:MM:SS)")))) (setq osmode (getvar "osmode")) (setvar "osmode" 0) (vl-cmdf ".undo" "be") (setq blc (getint "\n 请输入比例尺 1:")) (setvar 'userr1 blc) (setq zg (* 0.002 blc)) (setq scale (* 0.001 blc)) (setq ff (open (getfiled "请选择要展点的数据文件" "" "dat" 2) "r")) (setq decimal-places (getint "\n 请输入高程点小数位数:")) ; 新增:获取小数位数 (while (and (setq zb (read-line ff)) ) (while (and (vl-string-search "," zb) ) (setq zb (vl-string-subst " " "," zb)) ) (setq zb (read (strcat "(" zb ")"))) (setq id (nth 0 zb)) (if (= (length zb) 5) (progn (setq zpt (list (nth 2 zb) (nth 3 zb) (nth 4 zb))) ) (progn (setq zpt (list (nth 1 zb) (nth 2 zb) (nth 3 zb))) ) ) (setq p2 (polar zpt (* 0.25 pi) (* 1.5 zg))) (if (not (null zpt)) ; 增加对 zpt 不为空的检查 (progn (princ (strcat "ZPT: " (vl-princ-to-string zpt))) ; 调试输出 zpt (entmake (list '(0. "POINT") (cons 10 zpt) '(8. "ZDH") (list -3 (list "NAME" (cons 1000 (vl-princ-to-string (nth 0 zb)))) (list "CODE" (cons 1000 (vl-princ-to-string (nth 1 zb)))) time)) (entmake (list '(0. "TEXT") (cons 1 (vl-princ-to-string id)) (cons 10 p2) '(7. "HZ") '(8. "ZDH") (cons 40 zg) '(41. 0.8))) (gxl-cs:gcd zpt (caddr zpt) scale decimal-places (list "NAME" (cons 1000 (vl-princ-to-string (nth 0 zb))) (cons 1000 (vl-princ-to-string (nth 1 zb))))) ; 传递小数位数 ) ) ) (close ff) (command "undo") (command "e") (setvar "osmode" osmode) (princ "展点完成") (princ) ) )(defun gxl-cs:gcd(insp height scale decimal-places name / pt blkdef obj) ; 新增:接收小数位数参数 (setvar "cmdecho" 0) (command "layer") (command "m") (command "GCD") (command "c") (command "1") (command "") (command "L") (command "CONTINUOUS") (command "") (command "") (if height (progn (princ (strcat "Height before conversion: " (vl-princ-to-string height))) ; 调试输出 height 原始值 (setq height (rtos height decimal-places)) ; 使用输入的小数位数 (princ (strcat "Height after conversion: " (vl-princ-to-string height))) ; 调试输出转换后的 height ) (progn (setq height "") ) ) (regapp "SOUTH") (if (not (tblobjname "style" "HZ")) (progn (command "style") (command "HZ") (command "rs.shx,hztxt.shx") (command 0) (command 1) (command 0) (command "") (command "") (command "") ) ) (if (not (tblobjname "block" "GC200")) (progn (setq blkdef (vla-add (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point '(0 0 0)) "GC200")) (setq obj (vla-addpolyline blkdef (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble (cons 0 5)) '(-0.2 0 0 0.2 0 0)))) (vla-setbulge obj 0 1) (vla-setbulge obj 1 1) (vla-put-closed obj :vlax-true) (vla-put-constantwidth obj 0.4) ) ) (entmake (list '(0. "INSERT") '(100. "AcDbEntity") '(100. "AcDbBlockReference") '(66. 1) (cons 2 "GC200") (cons 10 insp) (cons 41 scale) (cons 42 scale) (cons 43 scale) (list -3 '("SOUTH" (1000. "202101")) name time))) (entmake (list '(0. "ATTRIB") '(100. "AcDbEntity") '(100. "AcDbText") (cons 10 (setq pt (polar insp 0 (* 1.2 scale)))) (cons 40 (* 2.0 scale)) (cons 50 0) (cons 41 0.8) (cons 51 0) (cons 1 height) (cons 7 "HZ") (cons 72 0) (cons 11 pt) '(100. "AcDbAttribute") (cons 2 "height") (cons 70 0) (cons 74 2))) (entmake '((0. "SEQEND"))) (princ) )
|
|