明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2155|回复: 0

:::关于vl与excel的连接!

[复制链接]
发表于 2002-5-30 19:33:00 | 显示全部楼层 |阅读模式
(vl-load-com)

            (setq *excel-cells* nil)
            (setq *row* nil)
      
            (defun init-excel (/ excel-app wb-colletion workbook sheets sheet1)
             (setq excel-app (vlax-create-object "excel.application"))
             (setq wb-collection (vlax-get excel-app "workbooks"))
             (setq workbook (vlax-invoke-method wb-collection "add"))
             (setq sheets (vlax-get workbook "sheets"))
             (setq sheet1 (vlax-get-property sheets "item" 1))
             (setq *excel-cells* (vlax-get sheet1 "cells"))
             (vlax-put excel-app "visible" 1))

            (defun write-row-column (row col x)
             (vlax-put-property *excel-cells* "item" row col (vl-princ-to-string x)))

            (setq *model-space* nil)

            (defun init-app ()
             (setq *model-space*
             (vla-get-modelspace
             (vla-get-activedocument
             (vlax-get-acad-object))))
             (write-row-column 1 1 "Centro x")
             (write-row-column 1 2 "Centro y")
             (write-row-column 1 3 "Centro z")
             (write-row-column 1 4 "Raio")
             (setq *row* 2))

            (defun add-circle (px py pz radius)
             (write-row-column *row* 1 px)
             (write-row-column *row* 2 py)
             (write-row-column *row* 3 pz)
             (write-row-column *row* 4 radius)
             (setq *row* (+ *row* 1))
             (vla-addcircle *model-space*
             (vlax-3d-point px py pz )
             radius))

            (defun c:demo ()
             (init-excel)
             (init-app)
             (add-circle 5 5 0 5)
             (add-circle 5 5 0 10))
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-30 20:13 , Processed in 0.163287 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表