首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Autocad VBA -创建广场

Autocad VBA -创建广场
EN

Stack Overflow用户
提问于 2017-12-05 20:24:13
回答 1查看 1K关注 0票数 1

我试图使用VBA在AutoCAD中创建一个简单的正方形,但是当我试图运行我的代码时,我会得到一个“超出范围”的错误?任何帮助都会很好!

代码语言:javascript
复制
Sub box()
'Link the Exel File to the open CAD File'
'If no CAD file open it does create one'
'----------------------------------------------------------------'
Dim ACAD As AcadApplication 'Create ACAD variable of type AcadApplication
On Error Resume Next 'This tells VBA to ignore errors
Set ACAD = GetObject(, "AutoCAD.Application") 'Get a running instance of the class AutoCAD.Application
On Error GoTo 0 'This tells VBA to go back to NOT ignoring errors
If ACAD Is Nothing Then 'Check to see if the above worked
    Set ACAD = New AcadApplication 'Set the ACAD variable to equal a new instance of AutoCAD
    ACAD.Visible = True 'Once loaded, set AutoCAD® to be visible
End If
ACAD.ActiveDocument.Utility.Prompt "Hello from Excel!" 'Print a message to the AutoCAD® command line

Dim squareObj As Acad3DSolid
Dim center(0 To 2) As Double

center(0) = 10
center(1) = 10
center(2) = 0

Set squareObj = ACAD.ActiveDocument.ModelSpace.AddBox(center, 2, 2, 0)

End Sub
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-16 12:36:33

从Autodesk

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-DE469E81-8531-415C-9D22-7041A42838DD-htm.html

代码语言:javascript
复制
RetVal = object.AddBox(Origin, Length, Width, Height)

盒子的高度。必须是一个正数,因为它看起来像是autocad不会创建一个零高度的三维实体。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47662060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档