VB调用Autocad的两种方法比较。
<p>1、在引用项中,Autocad XXX打勾。</p><p>2、用object方法。</p><p>在VB中,引用引用选择Autocad,可以像在AutoCAD一样操作方便。 问题存在(AutoCad不同版本问题),</p><p>Private Sub Form_Load()<br/> Dim ojbLine As AcadLine<br/> Dim pp(0 To 2) As Double, ppp(0 To 2) As Double<br/> For jj = 0 To 1<br/> pp(jj) = jj<br/> ppp(jj) = jj * 5<br/> Next jj<br/> Set objline = objModelSpace.AddLine(pp, ppp)<br/> Dim xlSheet1 As Worksheet<br/> Set xlSheet1 = xlsMdb.xlSheet<br/> For ii = 1 To 10<br/> xlSheet1.Cells(ii, 2) = ii<br/> Next ii<br/>End Sub</p><p>Function objModelSpace() As AcadModelSpace<br/> Dim appAutoCad As AutoCAD.AcadApplication<br/> On Error Resume Next<br/> Set appAutoCad = GetObject(, "AutoCAD.Application")<br/> If Err Then<br/> Err.Clear<br/> Set appAutoCad = CreateObject("AutoCAD.Application")<br/> <br/> End If<br/> appAutoCad.Visible = True<br/> Dim AcadDoc As AcadDocument<br/> Set AcadDoc = appAutoCad.ActiveDocument<br/> 'Dim objModelSpace As AcadModelSpace<br/> Set objModelSpace = AcadDoc.ModelSpace</p><p>End Function</p><p>用object方法操作不能像在autocad中自如。但不存在版本问题。!!</p><p>Dim obj_Acad As Object, obj_Doc As Object, obj_ModelSpace As Object<br/>Dim boo As Boolean</p><p>Public Sub AutoCADConnect() '连接AutoCAD<br/>On Error Resume Next<br/>Set obj_Acad = GetObject(, "autocad.application")<br/>If Err Then<br/> Err.Clear<br/> On Error Resume Next<br/> Set obj_Acad = CreateObject("autocad.application")<br/> If Err Then<br/> Err.Clear<br/> MsgBox "不能运行AutoCAD,请检查是否安装!", vbOKOnly, "警告!"<br/> Exit Sub<br/> End If<br/>End If<br/>obj_Acad.Visible = True<br/>Set obj_Doc = obj_Acad.ActiveDocument<br/>Set obj_ModelSpace = obj_Doc.ModelSpace<br/>MsgBox "运行结束!", vbOKOnly, "工程1!"<br/>boo = True<br/>End Sub</p><p>Private Sub Command1_Click()<br/>Call AutoCADConnect '调用连接AutoCAD的子程序<br/>End Sub<br/></p> <p>怎么看不太明白</p><p>收下仔细看</p><p>楼主是不是想讨论前期绑定和后期绑定的问题</p> <p>其实一直以来都佩服楼主功力深厚</p><p>一直困扰的一个问题,还请楼主赐教!</p><p>就是关于非连续面域的填充</p><p>一个非连续的面域(把符合条件的部分做成面域并且合并,但不是连续,就是好像群岛一样,但他们是一个整体、同一个面域)</p><p>填充完成之后(填充为指定颜色),填充物不可见(可以肯定是填充物确实存在,用快速选择可以找到)</p><p>可是连续的面域填充就没有问题</p><p>谢谢</p> <p>楼主有个问题请教:在VBA的程序如何调用LISP程序,并要求从LISP程序中获取一个值.</p>
页:
[1]