马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 lijiao 于 2021-1-7 16:04 编辑
近日无事,写了点代码,供大家测试一下. 程序提供了3个文件,setup.lsp vlapi.fas vlapi.dvb,3个文件需要放在cad的搜索路径中. Setup.lsp是源码,主要是检索和加载文件,一看就明白. Vlapi.dvb是vba工程文件,提供数据返回功能,大家不用关心. Vlapi.fas是编译后的文件,提供一下几个核心函数: (Runvba strpro [value]) (with [str/vla-object]) (wget pro) (wput pro value) (wmeth method [vars]) (select var) (case var)
(Runvba strpro [value])函数的用法: (runvba"thisdrawing.ModelSpace(0)")>>> #<VLA-OBJECT IAcadLine000001a2be9a93b8> (runvba"thisdrawing.ModelSpace(0).layer")>>>"AM_0" (runvba"thisdrawing.ModelSpace(0).layer" "AM_5")>>>nil (runvba"thisdrawing.ModelSpace(0).layer")>>>"AM_5" 还可以这样用: (runvba "userform1.showvbmodeless") (runvba"userform1.left" 100)
(with [str/vla-object]) (wget pro) (wputpro value) (wmeth method [vars]) 函数的用法: 这是一组函数,调用后三个函数前,需先用with函数,比如: (with 'cadapp)或 (with“cadapp”)均返回#<VLA-OBJECT IAcadApplication00007ff61c25b910> (with 'thisdrawing)返回#<VLA-OBJECT IAcadDocument 000001a2b0f97298> (with (VLAX-GET-ACAD-OBJECT))返回#<VLA-OBJECT IAcadApplication 00007ff61c25b910> (with "thisdrawing")返回"thisdrawing." 用法示例: (with "thisdrawing") (wget 'Name)或(wget “Name”)返回"Drawing1.dwg" (wget 'ModelSpace)或(wget“ModelSpace”)返回#<VLA-OBJECT IAcadModelSpace000001a2b0b841a8> (wget 'Width)或(wget”width”)返回1382 (with"thisdrawing.ModelSpace(0)") (wget 'layer)返回"AM_5" (wput 'layer "am_0")返回nil (wget 'layer)返回"AM_0" (wmeth method [vars])函数的用法想必大家都明白了,只是其前面with函数的变量必须为vla-object类型
(select var)和(case var)的用法就很简单了,举例: 假如obj_line为vla-object类型的直线 (select (vla-get-color obj_line)) (Cond ((case 1) (princ “\n红色”)) ((case 2) (princ “\n蓝色”)) )
|