在单元格中输入=ls()--------------- 采用的是excel的单元格自定义函数功能. 自定义函数function ls() 程序如下: 以下程序必须放在excel的bas模块中. Function ls() As Double Dim returnObj As AcadCircle Dim basePnt As Variant
With objModelDocument .Utility.GetEntity returnObj, basePnt, "选择一个圆" ls = returnObj.Area End With End Function
excel与AutoCAD通讯程序如下
Function objModelDocument() As AcadDocument Dim appAutoCad As AutoCAD.AcadApplication On Error Resume Next Set appAutoCad = GetObject(, "AutoCAD.Application") If Err Then Err.Clear Set appAutoCad = CreateObject("AutoCAD.Application") End If appAutoCad.Visible = True Dim AcadDoc As AcadDocument Set objModelDocument = appAutoCad.ActiveDocument End Function
|