[搬运]读文本画矩形
本帖最后由 tigcat 于 2024-3-20 19:57 编辑应该是可以读取文本,然后根据文本内容画矩形,搬运给新手坛友使用原帖地址:https://forums.autodesk.com/t5/v ... gles/td-p/12629624#
(defun c:kilama (/ *error* string_to_list f file1 redak x y w h d dx dy p1 p2) (defun *error* () (setvar 'cmdecho 1) (close file1) ) (defun string_to_list ( str del / pos ) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (string_to_list (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) (setvar 'cmdecho 0) (setq f (getfiled "Open File" (getvar "dwgprefix") "txt" 2)) (setq file1 (open f "r")) (while (setq redak (read-line file1)) (mapcar 'set '(x y w h d) (mapcar 'atof (string_to_list redak ","))) (setq dx (* 0.5 w) dy (* 0.5 h)) (setq p1 (mapcar '- (list x y) (list dx dy))) (setq p2 (mapcar '+ (list x y) (list dx dy))) (command "_.rectangle" p1 p2) (command "_.offset" d (entlast) (list x y) "") ) (close file1) (command "_.zoom" "e") (setvar 'cmdecho 1) (princ))
数据格式x,y,width,height, thicknessx,y,宽度,高度,厚度
100,100,150,150,25
500,500,150,150,25
300,300,150,150,25
1000,1000,150,150,25
1200,1200,150,150,25
感谢楼主分享,很好的代码,数据取值拓展空间很大,单个数据串连再分开读取,步骤清晰。 不会用 对,虽然简单,但有函数可用,我们可以学习借鉴。遇到类似时可以自己改造 感谢楼主,先收藏一下,得想想怎么才能用上 谢谢分享。 感谢楼主分享,很好的代码,
页:
[1]