sealive 发表于 2008-6-14 23:23:00

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-12 20:39:00

本帖最后由 作者 于 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/>&nbsp;&nbsp;&nbsp; '根据AutoCAD的版本判断使用的库类型<br/>&nbsp;&nbsp;&nbsp; If Left(ThisDrawing.Application.Version, 2) = "15" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")<br/>&nbsp;&nbsp;&nbsp; ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set VLF = VL.ActiveDocument.Functions<br/>End Sub</p>

wuyunpeng888 发表于 2009-2-22 19:24:00

我的有时候好用,有时候不好用,不知道是什么原因,我用的是2009

唐僧肉 发表于 2009-2-23 15:51:00

<p>在acad2009.lsp内加</p><p>(vl-load-com)就行了.</p>

唐僧肉 发表于 2009-2-23 16:01:00

本帖最后由 作者 于 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/>&nbsp;&nbsp;&nbsp; Dim obj As VLAX, retVal<br/>&nbsp;&nbsp;&nbsp; Set obj = New VLAX</p><p>&nbsp;&nbsp;&nbsp; obj.EvalLispExpression "(setq curve (handent " &amp; Chr(34) &amp; curve.Handle &amp; Chr(34) &amp; "))"<br/><br/>&nbsp;&nbsp;&nbsp; obj.EvalLispExpression "(setq cpnt (vlax-curve-getPointAtDist curve " &amp; dist &amp; "))"<br/>&nbsp;&nbsp;&nbsp; retVal = obj.GetLispList("cpnt")<br/>&nbsp;&nbsp;&nbsp; '释放内存,函数返回<br/>&nbsp;&nbsp;&nbsp; Set obj = Nothing<br/>&nbsp;&nbsp;&nbsp; GetcurvePoint_at_dist1 = retVal<br/>End Function</p><p></p>

wuyunpeng888 发表于 2009-2-24 10:20:00

我用的也是VBA

wuyunpeng888 发表于 2009-2-24 23:25:00

<p>Private Sub Class_Initialize()<br/>&nbsp;&nbsp;&nbsp; '根据AutoCAD的版本判断使用的库类型<br/>&nbsp;&nbsp;&nbsp; If Left(ThisDrawing.Application.Version, 2) = "15" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")<br/>&nbsp;&nbsp;&nbsp; ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set VLF = VL.ActiveDocument.Functions<br/>End Sub</p><p>这段代码为什么在我的机器上就不能用呢?说是加载应用程序出现问题,真是气死我了</p>

wuyunpeng888 发表于 2009-2-27 23:02:00

<p>这段程序应该改一下<br/>Private Sub Class_Initialize()<br/>With Application<br/>&nbsp;&nbsp;&nbsp; Select Case Left(.Version, 2)<br/>&nbsp;&nbsp;&nbsp; Case "15"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = .GetInterfaceObject("VL.Application.1")<br/>&nbsp;&nbsp;&nbsp; Case "16", "17"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set VL = .GetInterfaceObject("VL.Application.16")<br/>&nbsp;&nbsp;&nbsp; End Select<br/>&nbsp;&nbsp;&nbsp; Set VLF = VL.ActiveDocument.Functions<br/>End With<br/>End Sub<br/></p>
页: [1]
查看完整版本: VLAX.CLS类支持高版本吗?