本帖最后由 gamexia 于 2024-11-20 21:40 编辑
利用excel数据,插入块,cad 返回这个错误: no function definition: MSXL-GET-RANGE
是啥问题,帮看看
excel路径:
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
- (defun c:mapan ()
- (vl-load-com)
- (setq exname "d:\\ABC.xls")
- (setq *excel* (vlax-create-object "excel.application"))
- (setq *xlapp* (vlax-invoke-method (vlax-get-property *excel* 'Workbooks) 'Open exname))
- (vla-put-visible *excel* 1) ;;显示工作表
- (setq *sheet* (vlax-get-property (vlax-get-property *xlapp* 'Worksheets) 'item "DEF"))
- (setq pt (getpoint "\n选择需要插入块的基点:"))
- (setq mm 2) ;mm从第二行开始
- (repeat 1080
- ;;;从EXCEL的C列mm行读取块名
- (setq km (Ljx-read-excel-data "C" mm *sheet* ))
- ;;;从excel的B列mm行读取角度
- (setq jiaodu (Ljx-read-excel-data "B" mm *sheet*))
- (command "_insert" km pt 1 1 jiaodu );以pt为基点插入指定块,x比例1,y比例1,角度为指定jiaodu
- (setq mm (1+ mm))
- )
-
- (vlax-invoke-method (vlax-get-property *excel* "ActiveWorkbook") 'Close 0)
- (vlax-invoke-method *excel* 'QUIT)
- (vlax-release-object *sheet*)
- (vlax-release-object *xlapp*)
- )
- ;;;;;读取数excel数据函数
- (defun Ljx-read-excel-data1 (vv hor sh) ;;;vv为列数直接输入字母、hor为 第几行,直接输入数字,sh为工作表对象sheet
- (vlax-variant-value (vlax-get-property (vlax-get-property sh 'Range (strcat vv (itoa hor))) 'Value2))
- )
- ;;;;;读取数excel数据函数输出text格式
- (defun Ljx-read-excel-text1 (vv hor sh / ru) ;;;vv为列数直接输入字母、hor为 第几行,直接输入数字,sh为工作表对象sheet
- (vl-princ-to-string (vlax-variant-value (vlax-get-property (vlax-get-property sh 'Range (strcat vv (itoa hor))) 'Value2)))
- )
- (defun ljx-vlxls-get-range-value1 ( sheet rangeid / range value valuelist )
- (setq range (vlax-get-property sheet 'Range rangeid))
- (setq value (vlax-get-property range 'Value2))
- (cond
- ((= (vlax-variant-type value) 8204);;;为数组时,即为区域;
- (progn
- (setq value (vlax-safearray->list(vlax-variant-value value)))
- (setq valuelist (mapcar (function (lambda (x) (mapcar 'vlax-variant-value x))) value))
- )
- )
- ( T;;;;为单个单元格;
- (setq valuelist (vlax-variant-value value))
- )
- );;;;cond
- valuelist
- )
|