如何将excel中的数据坐标连同点号导入cad
3个回答
2015-10-07 · 知道合伙人软件行家
关注
展开全部
有两种方法。1、在cad中插入excel表格。(缺点:打开这个cad图形时电脑必须带有excel应用程序,否则无法显示。优点:操作简便
2、利用vba程序,读取excel表格后写入cad中。以下代码供参考。具体可能有做细微的调整。注:以下vba需在cad中运行的。如果是在excel中要修改。
Sub 根据excel自动画表()
Dim xlApp As Excel.Application
Set xlApp = GetObject(, "Excel.Application")
Dim xlSheet As Worksheet
Set xlSheet = xlApp.ActiveSheet
Dim iPt(0 To 2) As Double
iPt(0) = 0: iPt(1) = 0: iPt(2) = 0
Dim BlockObj As AcadBlock
Set BlockObj = ThisDrawing.Blocks("*Model_Space")
Dim xlRange As Range
For Each xlRange In xlSheet.UsedRange
AddLine BlockObj, xlRange
AddText BlockObj, xlRange
Next
Set xlRange = Nothing
Set xlSheet = Nothing
Set xlApp = Nothing
End Sub
2、利用vba程序,读取excel表格后写入cad中。以下代码供参考。具体可能有做细微的调整。注:以下vba需在cad中运行的。如果是在excel中要修改。
Sub 根据excel自动画表()
Dim xlApp As Excel.Application
Set xlApp = GetObject(, "Excel.Application")
Dim xlSheet As Worksheet
Set xlSheet = xlApp.ActiveSheet
Dim iPt(0 To 2) As Double
iPt(0) = 0: iPt(1) = 0: iPt(2) = 0
Dim BlockObj As AcadBlock
Set BlockObj = ThisDrawing.Blocks("*Model_Space")
Dim xlRange As Range
For Each xlRange In xlSheet.UsedRange
AddLine BlockObj, xlRange
AddText BlockObj, xlRange
Next
Set xlRange = Nothing
Set xlSheet = Nothing
Set xlApp = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询