错误: no function definition: VLA-GET-ACTIVEDOCUMENT
我运行了以下面积周长标注的LSP程序,以前都用着没什么的,这几天不知道怎么了,输入高度后再标注就会出现下图中的结果,我尝试重置我的2012的CAD就得到了解决,但是还没用多久就又出现了下图的提示,不知道究竟是哪里有错误,还是我按到了什么变量快捷键了,求大神帮忙解决:'(;单独做一个程序amset设置字高,再把单位改一下就行了
(defun C:amset()
(setq height (getdist "\n请输入文字高度:"))
(PRINC))
(defun C:am (/ ss l i totalarea ename obj entarea)
(if (setq ss (ssget))
(progn
(vl-load-com)
(setq modelspace (vla-get-Modelspace (vla-get-activeDocument (vlax-get-acad-object))))
(setq l (sslength ss) i 0 totalarea 0 totlength 0)
(repeat l
(setq ename (ssname ss i))
(setq obj (vlax-ename->vla-object ename))
;;(vlax-dump-object obj T)
(if (vlax-property-available-p obj "area")
(setq totalarea (+ (vlax-get-property obj 'area) totalarea))
)
(if (= (cdr (assoc 0 (entget ename))) "MLINE")
(setq totlength (+ totlength (ml-length ename)))
(setq totlength (+ totlength (vlax-curve-getdistatparam ename (vlax-curve-getendparam ename))))
)
(setq i (1+ i))
)
(setq text1 (strcat "面积为: " (rtos (/ totalarea 1000000) 2 4) "平方米")
text2 (strcat "长度为: " (rtos (/ totlength 1000) 2 4) "米")
)
(if (setq insertpt (getpoint "\n请输入文字插入点: "))
(if height
(setq insertp1 (vlax-3d-point insertpt)
insertp2 (vlax-3d-point (polar insertpt (* 1.5 Pi) (* 1.5 height)))
textobj1 (vla-addtext modelspace text1 insertp1 height)
textobj2 (vla-addtext modelspace text2 insertp2 height)
)
)
)
)
)
)
(defun ml-length (ename / j d ptlist)
(foreach n (entget ename)
(if (= (car n) 11)
(setq ptlist (cons (cdr n) ptlist))
)
)
(reverse ptlist)
(setq j 0 d 0)
(repeat (1- (length ptlist))
(setq d (+ d (distance (nth j ptlist) (nth (1+ j) ptlist))))
(setq j (1+ j))
)
d
)
这个是结果
命令: AMSET
请输入文字高度:200
命令:
命令: am
找到 1 个
; 错误: no function definition: VLA-GET-ACTIVEDOCUMENT
页:
[1]