代码是明经的,感谢原作者
批量选择文字粘贴为多行文字,这个点选的时候顺序没问题,框选的时候没有排序,会错乱,能否实现按左到右,上到下顺序排列成多行呢?
- ;
- (vl-load-com)
- (defun x-clip-string (str / html result)
- (and (= (type str) 'str)
- (setq html (vlax-create-object "htmlfile"))
- (setq result (vlax-invoke (vlax-get (vlax-get html 'parentwindow) 'clipboarddata ) 'setdata "text" str ))
- (vlax-release-object html))
- )
- (defun c:w2()
- (vl-load-com)
- (setq txtcon (strcat))
- (setq txtss (ssget '((0 . "*TEXT,DIMENSION"))))
- (setq ssv (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
- (setq i 0)
- (setq txtcon (strcat))
- (repeat (vla-get-count ssv)
- (setq txtcon (apply '(lambda (v) (setq txtcon (strcat txtcon v "\n")))
- (progn
- (if (= (vla-get-ObjectName (vla-item ssv i)) "AcDbRotatedDimension")
- (progn (if (= (vla-get-TextOverride (vla-item ssv i)) "")
- (setq pt (rtos (vla-get-Measurement (vla-item ssv i)) 2 2))
- (setq pt (vla-get-TextOverride (vla-item ssv i)) )))
- (setq pt (vla-get-TextString (vla-item ssv i)))
- )
- (list pt)
- )))
- (setq i (1+ i))
- )
- (x-clip-string txtcon)
- (princ "\n文字已复制到剪切板,可以直接粘贴了!")
- (princ)
- )
|