明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: mccad

VLAX类及曲线操作

  [复制链接]
发表于 2012-5-3 10:43:56 | 显示全部楼层
怎么应用呀,
发表于 2013-6-15 10:57:54 | 显示全部楼层
为什么用类函数,总是提示,错误 参数太少
发表于 2014-9-16 00:31:14 | 显示全部楼层
Private Sub Class_Initialize()

    If Left(ThisDrawing.Application.Version, 2) = "15" Then
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
    Else
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
    End If
     Set VLF = VL.ActiveDocument.Functions

End Sub
发表于 2015-11-4 12:12:51 | 显示全部楼层
通过运行,发现在以下代码运行时不稳定,报错
Private Sub Class_Initialize()
    If Left(ThisDrawing.Application.Version, 2) = "15" Then
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
    Else
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
    End If
     Set VLF = VL.ActiveDocument.Functions
End Sub
在参考其他源码,发现做如下变动,运行就比较稳定
Private Sub Class_Initialize()
   ThisDrawing.SendCommand "(vl-load-com)" & vbCr '首先要加载VL接口,因为后面的函数是基于它的。本句为新添加语句,其他不变
    If Left(ThisDrawing.Application.Version, 2) = "15" Then
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
    ElseIf Left(ThisDrawing.Application.Version, 2) = "16" Then
     Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
    End If
    Set VLF = VL.ActiveDocument.Functions
End Sub
运行环境:XP3,CAD2006,VB6
回复 支持 1 反对 0

使用道具 举报

发表于 2020-11-26 09:44:39 | 显示全部楼层
版主,麻烦请教个问题。vb进行cad二次开发的时候,如果想引用vlax和curve这两个类,是不是得在引用中添加类库,请问是哪个类库?
发表于 2020-11-26 15:25:26 | 显示全部楼层
请问楼主VLAX类 - VLAX.cls和Curve.cls两个类块怎么导入
发表于 2021-6-15 22:48:40 | 显示全部楼层
有没有大神解释下  Curve类模块中 GetClosestPointToProjection 的Normal参数在VBA中如何指定啊?
多谢!

Public Function GetClosestPointToProjection(Point As Variant, Normal As Variant, Optional Extend As Boolean = False) As Variant

    Dim retval As Variant, pt(0 To 2) As Double
    Dim i As Long
   
    With objVLAX
        .SetLispSymbol "handle", mvarEntity.Handle
        .SetLispSymbol "givenPt", Point
        .SetLispSymbol "normal", Normal
        If Extend Then .EvalLispExpression "(setq ext T)"
        .EvalLispExpression "(setq lst (vlax-curve-getClosestPointToProjection (handent handle) givenPt normal ext))"
        retval = .GetLispList("lst")
        .NullifySymbol "handle", "lst", "normal", "ext", "givenPt"
    End With
   
    For i = 0 To 2
        pt(i) = retval(i)
    Next
   
    GetClosestPointToProjection = pt

End Function
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-16 20:44 , Processed in 0.159337 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表