;;;从AutoCAD 2013 Active Reference帮助中code Examples中提取 ;;;本源代码由 xshrimp 2013.2.20 搜集整理,版权归原作者所有! (vl-load-com) (defun c:Example_InsertionPoint() ;; This example creates a text object in model space. ;; It then changes the insertion point of the text object. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Define the text object (setq textString "Hello, World." insertionPoint (vlax-3d-point 2 2 0) height 0.5) ;; Create the text object in model space (setq modelSpace (vla-get-ModelSpace doc)) (setq textObj (vla-AddText modelSpace textString insertionPoint height)) (vla-ZoomAll acadObj) ;; Return the current value of the insertion point (setq currInsertionPoint (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint textObj)))) (alert (strcat "The insertion point of the text is " (rtos (nth 0 currInsertionPoint) 2) ", " (rtos (nth 1 currInsertionPoint) 2) ", " (rtos (nth 2 currInsertionPoint) 2))) ;; Change the insertion point of the text object and ;; update the display of the text object. (setq insertionPoint (vlax-3d-point 3 3 0)) (vla-put-insertionPoint textObj insertionPoint) (vla-Update textObj) (setq newInsertionPoint (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint textObj)))) (alert (strcat "The new insertion point of the text is " (rtos (nth 0 newInsertionPoint) 2) ", " (rtos (nth 1 newInsertionPoint) 2) ", " (rtos (nth 2 newInsertionPoint) 2))) )