陈伟 发表于 2024-3-21 22:16

仿CASS坐标展点

本帖最后由 陈伟 于 2024-3-22 23:08 编辑






命令:ZD



展点后是属性块,如图

现在两个文件配合着用,一个展点高程,一个展点编号;用图框比例这个文件调整属性块的及文字大小


注意:VLX程序XY坐标反着的,源码坐标正确。测绘数据文件后缀名自行改成DAT格式后再做测试

yshf 发表于 2024-3-23 21:41

能不能将它们二合一,展点后为一个属性块,高程点右侧上方、点号在点右侧下方,一次可以看清高程及点号

leedun 发表于 2024-4-26 20:25

坐标展点高程为0,能不能修改一下

moshouhot 发表于 2024-5-20 00:14

(DEFUN PARSE2 (STR DELIM / LST POS)
(while (and (setq POS (VL-STRING-SEARCH DELIM STR)))
    (setq LST (APPEND LST (LIST (SUBSTR STR 1 POS))))
    (setq STR (SUBSTR STR (+ 2 POS)))
)
(if (> (STRLEN STR) 0)
                (PROGN (APPEND LST (LIST STR)))
    (PROGN LST)
)
)


; 定义一个新函数get-last-three,用于获取列表中的最后三个元素
(defun get-last-three (lst / len)
(setq len (length lst)) ; 获取列表的长度
(if (<= len 3) ; 如果列表长度小于或等于3
    lst ; 直接返回列表
    (progn ; 否则执行以下步骤
      (repeat (- len 3) ; 重复执行,直到列表只剩下三个元素
      (setq lst (cdr lst)) ; 移除列表的第一个元素
      )
      lst ; 返回最后三个元素
    )
)
)


(defun c:TT2 ()
        (setq S "Pt1,1,2,3,4,609036.512,2730628.308,1463.504")
        ; 使用get-last-three函数获取最后三个坐标值
        ;(setq P (get-last-three (PARSE2 S ",")))
       
       
        ; 使用PARSE2函数解析字符串S
        (setq P (PARSE2 S ","))
        (print P)
        ; 使用get-last-three函数获取最后三个坐标值
        (setq P (get-last-three P))
       
)

moshouhot 发表于 2024-5-20 23:33

(defun slice-list (lst start end / len sliced result i); 定义一个函数,用于切片列表
(setq len (length lst)) ; 获取列表长度
(setq sliced nil) ; 初始化切片列表
(setq result nil) ; 初始化结果列表
; 处理负索引和 end 为 nil 的情况
(if (< start 0); 如果开始索引为负数,转换为正索引
    (setq start (+ len start))
)

(if (null end); 如果结束索引为 nil,设置为列表长度
    (setq end len)
)
(if (< end 0); 如果结束索引为负数,转换为正索引
    (setq end (+ len end))
)
(if (and (listp lst) (numberp start) (numberp end) (<= start end)); 检查参数类型和范围
    (progn; 如果参数有效,则进行切片操作
      (setq sliced lst) ; 复制原列表到切片列表
      (setq i 0) ; 初始化计数器
      (repeat start; 使用 repeat 和 cdr 模仿 nthcdr 功能
      (setq sliced (cdr sliced)) ; 逐步缩减切片列表以模拟 nthcdr
      )
      (setq i start) ; 设置 i 为开始索引
      (while (and sliced (> end i)); 遍历列表并构建切片
      (setq result (cons (car sliced) result)) ; 将当前元素添加到结果列表
      (setq sliced (cdr sliced)) ; 指向下一个元素
      (setq i (+ i 1)) ; 更新计数器
      )
      (reverse result) ; 反转结果列表以保持原始顺序
    )
    (alert "Invalid arguments for slicing.") ; 参数无效时的警告
)
)
(defun c:ttt (); 定义名为 "ttt" 的命令程序
(setq mylist '(1 2 3 4 5 6 7 8 9)) ; 初始化一个列表
; 获取前三个元素
(setq first-three (slice-list mylist 0 3))
(princ first-three) ; 输出前三个元素
; 获取最后三个元素,支持负索引
(setq last-three (slice-list mylist -3 nil))
(princ last-three) ; 输出最后三个元素
; 获取中间三个元素,第2个元素 (索引为1) 到第5个元素 (索引为4)
(setq middle-three (slice-list mylist 1 4))
(princ middle-three) ; 输出中间三个元素
)

moshouhot 发表于 2024-5-20 23:46

版权归原作者所有,增加了切片功能,可以轻松定位dat里面的xyz。
页: [1]
查看完整版本: 仿CASS坐标展点