VLAX.CLS类支持高版本吗?
本帖最后由 作者 于 2008-6-14 23:24:34 编辑 <br /><br /> <p>VBA中VLAX.CLS类支持高版本吗?如ACAD2008、2009</p><p>vl16.tlb 编程接口是否支持编程!</p><p>高版本中使用VLAX.CLS失败!</p><p>classname=VL.Application.16</p><p></p> 本帖最后由 作者 于 2009-2-16 10:19:19 编辑 <br /><br /> <p>16改17就可以了.</p><p>不知道我说清楚了没.</p><p>版本号是17,但vl还是16的版本.</p><p>Private Sub Class_Initialize()<br/> '根据AutoCAD的版本判断使用的库类型<br/> If Left(ThisDrawing.Application.Version, 2) = "15" Then<br/> Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")<br/> ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then<br/> Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")<br/> End If<br/> <br/> Set VLF = VL.ActiveDocument.Functions<br/>End Sub</p> 我的有时候好用,有时候不好用,不知道是什么原因,我用的是2009 <p>在acad2009.lsp内加</p><p>(vl-load-com)就行了.</p> 本帖最后由 作者 于 2009-2-23 19:51:13 编辑 <br /><br /> <p>贴个返回曲线上定距离点坐标的函数吧.</p><p>Public Function GetcurvePoint_at_dist1(ByVal dist As Double, curve As AcadEntity) As Variant<br/> Dim obj As VLAX, retVal<br/> Set obj = New VLAX</p><p> obj.EvalLispExpression "(setq curve (handent " & Chr(34) & curve.Handle & Chr(34) & "))"<br/><br/> obj.EvalLispExpression "(setq cpnt (vlax-curve-getPointAtDist curve " & dist & "))"<br/> retVal = obj.GetLispList("cpnt")<br/> '释放内存,函数返回<br/> Set obj = Nothing<br/> GetcurvePoint_at_dist1 = retVal<br/>End Function</p><p></p> 我用的也是VBA <p>Private Sub Class_Initialize()<br/> '根据AutoCAD的版本判断使用的库类型<br/> If Left(ThisDrawing.Application.Version, 2) = "15" Then<br/> Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")<br/> ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then<br/> Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")<br/> End If<br/> <br/> Set VLF = VL.ActiveDocument.Functions<br/>End Sub</p><p>这段代码为什么在我的机器上就不能用呢?说是加载应用程序出现问题,真是气死我了</p> <p>这段程序应该改一下<br/>Private Sub Class_Initialize()<br/>With Application<br/> Select Case Left(.Version, 2)<br/> Case "15"<br/> Set VL = .GetInterfaceObject("VL.Application.1")<br/> Case "16", "17"<br/> Set VL = .GetInterfaceObject("VL.Application.16")<br/> End Select<br/> Set VLF = VL.ActiveDocument.Functions<br/>End With<br/>End Sub<br/></p>
页:
[1]