更好的 Autocad VBA 编辑器

发布于 2024-10-24 16:37:27 字数 267 浏览 7 评论 0原文

我正在 Autocad 中开发一些 VBA 宏。内置编辑器已过时,但我无法找到任何更好的方法来编辑 .dvb 文件。

.dvb 文件确实包含许多其他打包的源文件,到目前为止,我认为 Autocad 是唯一可以解压它们的软件......

它似乎能够做到这一点的唯一方法,是手动导出 .dvb 中的每个文件;但由于我那里有大约 30 个文件,这似乎不是一个好方法。

关于如何做得更好有什么想法吗?

I'm developing some VBA macros in Autocad. The built-in editor is obsolete, but I wasn't able to find any better way to edit the .dvb files.

A .dvb file does contains many other source files packed in, and so far I think that Autocad is the only software that can unpack them...

The only way it seems to be able to do this, is to export every file from the .dvb manually; but since I have about 30 files there, it doesn't seem like this is a good way to do things.

Any ideas on how to do this better?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过度放纵 2024-10-31 16:37:27

您可以使用以下代码导出所有文件:

Public Sub Export()
    Dim vbe As vbe
    Set vbe = ThisDrawing.Application.vbe
    Dim comp As VBComponent
    Dim outDir As String
    outDir = "C:\\Temp\\VbaOutput"
    If Dir(outDir, vbDirectory) = "" Then
        MkDir outDir
    End If
    For Each comp In vbe.ActiveVBProject.VBComponents
        Select Case comp.Type
            Case vbext_ct_StdModule
                comp.Export outDir & "\" & comp.Name & ".bas"
            Case vbext_ct_Document, vbext_ct_ClassModule
                comp.Export outDir & "\" & comp.Name & ".cls"
            Case vbext_ct_MSForm
                comp.Export outDir & "\" & comp.Name & ".frm"
            Case Else
                comp.Export outDir & "\" & comp.Name
        End Select
    Next comp

     MsgBox "VBA files were exported to : " & outDir
End Sub

You can export all your files with this code :

Public Sub Export()
    Dim vbe As vbe
    Set vbe = ThisDrawing.Application.vbe
    Dim comp As VBComponent
    Dim outDir As String
    outDir = "C:\\Temp\\VbaOutput"
    If Dir(outDir, vbDirectory) = "" Then
        MkDir outDir
    End If
    For Each comp In vbe.ActiveVBProject.VBComponents
        Select Case comp.Type
            Case vbext_ct_StdModule
                comp.Export outDir & "\" & comp.Name & ".bas"
            Case vbext_ct_Document, vbext_ct_ClassModule
                comp.Export outDir & "\" & comp.Name & ".cls"
            Case vbext_ct_MSForm
                comp.Export outDir & "\" & comp.Name & ".frm"
            Case Else
                comp.Export outDir & "\" & comp.Name
        End Select
    Next comp

     MsgBox "VBA files were exported to : " & outDir
End Sub
半边脸i 2024-10-31 16:37:27

如果您不想使用上述 Export() 子例程修改代码,可以使用 VBA2VB 表单由 Leslie Lowe 编写的 Converter 宏,或 修改版本由 Autodesk 开发者网络的 Augusto Gonçalves 编写。该宏的额外好处是能够将简单的 VBA 形式转换为 VB6 形式。如果您希望将来能够将项目移植到 .NET,则需要执行此操作,因为 AutoCAD 正在放弃 VBA 支持。宏的修改版本特别好,因为它将创建进行迁移所需的 .vbproj ASCII 文件,否则您需要旧版 Visual Basic 6 的副本IDE来制作。

FWIW,如果您想查看其中的内容,可以使用 7-Zip 等存档实用程序打开 .dvb 文件 - 但它似乎已编译,如果您想查看它也没有帮助人类可读或可导出的代码。

If you don't feel like modifying your code with the above Export() subroutine, you can export your VBA code from the .dvb file using the VBA2VB Form Converter macro written by Leslie Lowe, or the modified version written by Augusto Gonçalves of the Autodesk Developer Network. This macro has the added bonus of being able to convert simple VBA forms to VB6 forms. You'll need to do this if you want to be able to port the project to .NET in the future, as AutoCAD is dropping VBA support. The modified version of the macro is especially nice, as it will create the .vbproj ASCII file that you'll need to do the migration, which you'd otherwise need a copy of the old Visual Basic 6 IDE to make.

FWIW, A .dvb file can be opened using an archive utility like 7-Zip, if you want to see what's in it -- but it appears to be compiled, and isn't helpful if you want human-readable or exportable code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文