我接受了李的建议,因为它非常巧妙,将文本DXF代码直接转换为块的DXF代码。我通常不使用entmake,因为至少对我来说,它会生成繁琐而难看的列表。。。但是,它确实有它的好处。
在这里;如果你还需要什么,请告诉我。我很确定我的量表是正确的。
- (defun c:txttoblk( / ss e)
- (vl-load-com)
- (setq blk "BLOCK") ; Put block name here, with directory if block is not already in drawing
- (setq ss (ssget "X" '((0 . "TEXT")(1 . "F"))))
- (if ss
- (progn
- (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
- (mapcar '(lambda (x)
- (setq e (entget x))
- (entmake
- (append
- (list (cons 0 "INSERT") (cons 100 "AcDbEntity") (cons 100 "AcDbBlockReference")
- (cons 410 (cdr (assoc 410 e)))
- (cons 8 (cdr (assoc 8 e)))
- (cons 2 blk)
- (cons 10 (cdr (assoc 10 e)))
- (cons 41 (* (/ 32.0 3) (cdr (assoc 40 e))))
- (cons 42 (* (/ 32.0 3) (cdr (assoc 40 e))))
- (cons 50 (cdr (assoc 50 e))))
- )
- )
- (entdel x)) ss)
- )
- (princ "\nNo text entities found.")
- )
- (princ)
- )
|