错误: 参数类型错误: VLA-OBJECT nil
请教大家。有个lsp文件,以前好像正常,现在系统是win 11,CAD2010,提示错误: 参数类型错误: VLA-OBJECT nil,请问该怎样解决?源码如下:
(princ "\n第一种情况,要修改的标注数值=点选的一个或几个标注数值之和,请输入 t1 命令。\n第二种情况,要修改的标注数值等于点选的其他标注数值加一个数值,请输入 t2 命令。\n第三种情况,要修改的文本值等于点选的其他文本值,请输入t3命令。\n制作者:xvjiex 2020.12.3\n")
(vl-load-com)
(defun c:t1 (/ DIMZIN_bak ent t1 ss t-all L)
(setq DIMZIN_bak(getvar "DIMZIN"))(setvar "DIMZIN" 8)
(setq ent (xv:choose_ob "DIMENSION" "请选择需要被修改的标注"))
(setq t1 (vla-get-textoverride (vlax-ename->vla-object (car ent))))
(princ "\n 请选择多个需要累加的标注")
(setq ss (sslist(ssget'((0 . "DIMENSION")))))
(setq t-all (apply '+ (mapcar '(lambda(x)(if(=""(setq L(vla-get-textoverride (vlax-ename->vla-object x))))(vla-get-Measurement (vlax-ename->vla-object x))(atof L)))ss)))
(vla-put-textoverride (vlax-ename->vla-object (car ent)) (rtos t-all 2 2));;2 0表示结果保留0位小数,2 1表示保留1位小数
(setvar "DIMZIN" DIMZIN_bak)
(princ)
)
(defun c:t2 (/ DIMZIN_bak ent t1 ent2 *dist* jingdu1 L)
(setq DIMZIN_bak(getvar "DIMZIN"))(setvar "DIMZIN" 8)
(setq ent (xv:choose_ob "DIMENSION" "请选择需要被修改的标注"))
(or *dist*(setq *dist* 50))
(Initget 128 "D")
(while (or(=(setq ent2 (entsel (strcat"\n请选择参考标注,改递增数值请按D键:< "(rtos *dist* 2 2)">")))"D")(null ent2)(not (wcmatch (cdr (assoc 0 (entget (car ent2)))) "DIMENSION")))
(cond((= ent2 "D")(setq jingdu1 (getreal (Strcat "\n请输入要加的数值<" (rtos *dist* 2 2) ">:")))(if jingdu1 (setq *dist* jingdu1))))
(Initget 128 "D")
)
(setq t1 (if(=""(setq L(vla-get-textoverride (vlax-ename->vla-object (car ent2)))))(vla-get-Measurement (vlax-ename->vla-object (car ent2)))(atof L)))
(vla-put-textoverride (vlax-ename->vla-object (car ent)) (rtos (+ *dist* t1) 2 2));;2 0表示结果保留0位小数,2 1表示保留1位小数
(setvar "DIMZIN" DIMZIN_bak)
(princ)
)
(defun xv:choose_ob (st msj / a)
(if (setq a (entsel msj))
(if (wcmatch (cdr (assoc 0 (entget (car a)))) st) ;图元属性
a
(progn (alert (strcat"****选择错误!****\n"msj))
(princ (cdr (assoc 0 (entget (car a)))))(xv:choose_ob st msj)
)
)
(xv:choose_ob st msj)
)
)
(defun ssp(ss)
(= (type ss) 'PICKSET)
)
(defun sslist(ss / i lst)
(setq i -1)
(if (ssp ss)
(repeat (sslength ss)
(setq lst (cons (ssname ss (setq i (1+ i))) lst))
)
)
(reverse lst)
)
;;;Created by Sam 幸朝阳
;--------------该命令可让图中的多个文本实体变成某个文件实体
(DEFUN C:t3(/ XGE XX1 XX2 X XPH XGH XKX XX)
(setq XGE 0)
(PRINC "\n选择单个源文本实体:")
(setq X (SSGET))
(setq XX2 (CDR (ASSOC '1 (ENTGET (SSNAME X 0)))));提取实体字串
(PRINC "\n选择多个要修改的文本实体:")
(setq XGH (SSGET))
(setq XPH (SSLENGTH XGH))
(setq XKX (LIST ""))
(while (< XGE XPH)
(setq XX (CDR (ASSOC '1 (ENTGET (SSNAME XGH XGE)))));提取实体字串
(setq XX1 (ATOF XX))
(ENTMOD (SUBST (CONS 1 XX2)
(ASSOC '1 (ENTGET (SSNAME XGH XGE)))
(ENTGET (SSNAME XGH XGE))))
(setq XGE (+ XGE 1)))
)
(princ "\启动命令:t3")
我是这样解决的(我的是cad 2020,x64位系统):
1、查看“x:\Program Files\Autodesk\AutoCAD 2020\vl16.tlb”是否损坏或丢失。
x为安装盘符。
2、将附件导入注册表(也可打开注册表逐个检查修改)。
szhorse 发表于 2022-11-17 10:35
我是这样解决的(我的是cad 2020,x64位系统):
1、查看“x:\Program Files\Autodesk\AutoCAD 2020\vl16. ...
还是一样的提示错误 问这样问题的基本无从下手 估计要贴源码了:D- 设置CAD启动兼容WIN7 64位,且管理员模式,试一试。如果不行,是源码有BUG。 尘缘一生 发表于 2022-11-17 09:25
设置CAD启动兼容WIN7 64位,且管理员模式,试一试。如果不行,是源码有BUG。
win 11家庭版,按上述设置,被用户账户控制禁止了 插件我运行没问题 使用是可以正常使用,就提示错误。win 11家庭版的锅?
页:
[1]
2