- ;; 定义一个函数,用于设置单行文字Z坐标
- (defun c:settextz ()
- (vl-load-com)
- ;; 获取当前文档中的所有单行文字
- (setq entities (vlax-get-Objects (vla-get-activedocument (vlax-get-acad-object)) '((0 . "TEXT"))))
- (foreach entity entities
- (setq text (vlax-get-property entity 'textString))
- (setq position (vlax-get-property entity 'insertionpoint))
- ;; 设置单行文字的Z坐标为0
- (setq position (vlax-safearray->list (vlax-make-safearray vlax-vbDouble (cons 0 3))))
- (setq (nth 0 position) (car (vlax-safearray->list (vlax-get-property entity 'insertionpoint))))
- (setq (nth 1 position) (cadr (vlax-safearray->list (vlax-get-property entity 'insertionpoint))))
- (setq (nth 2 position) 0)
- (vla-put-textString entity text position)
- (vlax-release-object entity)))
- (princ))
以上代码由ChatGPT给出
|