在同一窗口中打开多个autocad文件vb.6代码
我有一个记事本,我在其中指定了dwg文件的所有路径,例如:c:\first.dwgd:\folderr1\second.dwg。dwg我正在寻找;vb.6程序,该程序将在同一窗口而不是单独的窗口中打开所有dwg图形你是说相同的会话窗口吗
可以用Lisp完成,因为这是Lisp论坛 ;如果需要VB6解决方案,则可能需要移动此线程。 我惊讶地看到,通用的;getObject“;调用,使用;Acad。应用程序;,不会返回当前正在运行的acad实例。我必须在调用中指定版本才能获得正在运行的实例。否则,启动acad的*第二个*实例
以下代码适用于我-我使用了“;Acad.Application。17“;,这是Autocad 2008。
我还在我的根目录(Dim DwgToOpen As String)中暗显了图形的名称,当然,您会想更改它
;这段代码是在Excel下创建的,不是VB6,我在工作中没有VB6,但该死的,后期绑定就是后期绑定
技巧的一部分是在不使用路径名参数的情况下调用getobject,但使用逗号:Set acApp=getobject(,“AutoCAD.Application.17”)
如果acad未运行,则在没有错误陷阱的情况下出错。因此,我们首先尝试该版本的调用,在需要时捕捉错误,然后,如果必须尝试';标准#039;调用的版本:
设置acApp=CreateObject(“AutoCAD.Application.17”)
如果找不到正在运行的实例,则创建一个新实例Sub Main()
Dim acApp As Object
' make sure under "Tools|Options|General" you select "Break on Unhandled Errors" selected
' Dim a Dwg Name to open in acad
Dim DwgToOpen As String: DwgToOpen = "c:\test.dwg"
On Error Resume Next ' call errors out if Acad 2008 not running
' get running instance of AutoCad
Set acApp = GetObject(, "AutoCAD.Application.17")
On Error GoTo 0
' if we dont have it, create from scratch
If acApp Is Nothing Then ' start new session of Autocad
Set acApp = CreateObject("AutoCAD.Application.17")
If acApp Is Nothing Then
MsgBox "Unable to open Autocad 2008"
Set acApp = Nothing
Exit Sub
Else
MsgBox "We are running a new instance of acad 2008"
End If
Else
MsgBox "We are using the current running Aacad 2008"
End If
' well, we have an instance of acad ruinning, whether an already running version,
' or a new version. Open the drawing in acad, as read-only
Dim MyDwg As Object
Set MyDwg = acApp.Documents.Open(DwgToOpen, True)
End Sub
页:
[1]