文件格式要求为文本格式,每行两个数据,以空格分隔,第一个为距离,第二个为角度(度单位),如
1.19 120
1.20 130
2.15 140
1.19 150
1.17 160

- (defun xd-mkline (p1 p2)
- (if (setq ent (entmakex (list '(0 . "LINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbLine")
- (cons 10 p1)
- (cons 11 p2)
- '(210 0. 0. 1.)
- )
- )
- )
- ent
- )
- )
- ;;文件转换为表
- ;;fn 全路径文件名
- (defun xd-readfile (fn / f l ll)
- (setq f (open fn "r"))
- (while (setq l (read-line f))
- (setq ll (cons (read (strcat "(" l ")")) ll))
- )
- (close f)
- ll
- )
- ;;制作做块头
- (defun xd-MKblock (blockname pt / blocktype)
- (if (or (/= 'STR (type blockname)) (= "" blockname))
- (setq blockname "*A")
- )
- (if (= (substr blockname 1 1) "*")
- (setq blocktype 1
- blockname "*A"
- )
- (setq blocktype 0)
- )
- (entmake (list
- '(0 . "BLOCK")
- '(100 . "AcDbEntity")
- '(100 . "AcDbBlockBegin")
- (cons 2 blockname)
- (cons 70 blocktype) ;_'(70 . 2);_属性块
- (cons 10 pt)
- )
- )
- )
- ;;;做块尾
- (defun xd-MKENDBLK ()
- (entmake '((0 . "ENDBLK")))
- )
- ;;;插入图块
- (defun xd-MkINSERT (bname ins-pt)
- (entmakex (list
- '(0 . "INSERT")
- '(100 . "AcDbEntity")
- '(100 . "AcDbBlockReference")
- ;;'(66 . 1);_属性
- (cons 2 bname)
- (cons 10 ins-pt)
- )
- )
- )
- (defun xd-dtr (j$) (* (/ j$ 180.0) pi))
- (defun c:tt (/ fn p lst blkna)
- (if (and (setq fn (getfiled "Select Points file" "" "txt" 8))
- (setq p (getpoint "\nBase Point: "))
- )
- (progn
- (command ".undo" "be")
- (setq lst (xd-readfile (findfile fn)))
- (xd-MKblock "*U" p)
- (xd-mkline (polar p pi 0.2)
- (polar p 0. 0.2)
- )
- (xd-mkline (polar p (/ pi 2) 0.2)
- (polar p (- (/ pi 2)) 0.2)
- )
- (mapcar
- '(lambda (x)
- (xd-mkline p (setq p1 (polar p (xd-dtr (cadr x)) (car x))))
- (xd-mkline p1 (polar p1 (+ (angle p1 p) (xd-dtr 10.)) 0.1))
- (xd-mkline p1 (polar p1 (- (angle p1 p) (xd-dtr 10.)) 0.1))
- )
- lst
- )
- (setq blkna (xd-mkendblk))
- (xd-mkinsert blkna p)
- (command ".undo" "end")
- )
- )
- (princ)
- )
|