超级绑定,可以一起绑定(bind)很多图纸。
<FONT face=Tahoma></FONT>大家可以用一下吧 能否讲讲起用途 用用看!! 先试试! 用途我已经说了,可以把带有xref的很多图纸,一起把xref绑定进来。这样这些图纸就不会随着xref的变化而变化了。 我觉得这个程序有点问题:
'Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long<BR>Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
<BR>Private Sub File1_Click()
End Sub
Private Sub cmdAddSource_Click()
<BR> Dim strfilepath As String
If fileSource.ListCount > 0 Then<BR> <BR> If Right(dirSource.Path, 1) = "\" Then<BR> strfilepath = dirSource.Path + fileSource.FileName<BR> Else<BR> strfilepath = dirSource.Path + "\" + fileSource.FileName<BR> End If<BR> <BR> txtdwgsource.Text = strfilepath<BR> <BR> End If<BR>End Sub
Private Sub cmdBind_Click()
If InStr(txtNewPath, "\") = 0 Then
MsgBox ("Please select the SaveAs path from the folder list above and click SaveAs button")<BR> Exit Sub<BR>End If
<BR>If lstBind.ListCount = 0 Then
Exit Sub<BR>End If
<BR>Dim ACADobj As AutoCAD.AcadApplication<BR>Dim DOC As AutoCAD.AcadDocument<BR>'Dim MSpace As AutoCAD.AcadPaperSpace<BR>Dim Layouts As AutoCAD.AcadLayouts<BR>Dim titleb As Object
<BR>Dim count As Integer
Dim strdwgfile As String
Dim result As String
Dim i, j, ips As Integer<BR>Dim strNewpath As String
Dim iWidth, iHeight As Integer
<BR>result = strtextfile
StatusBar1.SimpleText = "Bind is processing......"
Set ACADobj = CreateObject("AutoCAD.Application")
'ACADobj.Documents.Open (strdwgfile)<BR>'ACADobj.Documents.Add<BR>ACADobj.Application.Visible = False<BR>iWidth = ACADobj.Application.Width<BR>iHeight = ACADobj.Application.Height<BR>ACADobj.Application.Width = 1<BR>ACADobj.Application.Height = 1
Set DOC = ACADobj.ActiveDocument
<BR>If Dir("c:\userdata\test.scr") = "test.scr" Then<BR> Kill ("c:\userdata\test.scr")<BR>End If
Open CStr("c:\userdata\test.scr") For Output As #1
For i = 0 To lstBind.ListCount - 1
Print #1, "OPEN " & lstBind.List(i)<BR> Print #1, ";U2D"<BR> Print #1, "XREF"<BR> Print #1, "B"<BR> Print #1, "*"<BR> Print #1, "SaveAs"<BR> Print #1,<BR> If Trim(txtNewPath.Text) <> "" And Len(txtNewPath.Text) > 0 Then<BR> strdwgfile = lstBind.List(i)<BR> Do While InStr(strdwgfile, "\") > 0<BR> strdwgfile = Right(strdwgfile, (Len(strdwgfile) - InStr(strdwgfile, "\")))<BR> Loop<BR> <BR> Print #1, txtNewPath.Text + strdwgfile<BR> If Dir(txtNewPath.Text + strdwgfile) = strdwgfile Then<BR> <BR> If MsgBox("The File in " + txtNewPath.Text + strdwgfile + " exists, confirm overwrite?", vbOKCancel, "File Exist Alert") = vbOK Then<BR> <BR> Kill (txtNewPath.Text + strdwgfile)<BR> Else<BR> <BR> Close #1<BR> Kill ("c:\userdata\test.scr")<BR> StatusBar1.SimpleText = "Bind is unsucessful."<BR> DOC.Close (SaveChanges)<BR> ACADobj.Application.Width = iWidth<BR> ACADobj.Application.Height = iHeight<BR> ACADobj.Quit<BR> Exit Sub<BR> End If<BR> End If<BR> Else<BR> <BR> Print #1, lstBind.List(i)<BR> <BR> End If<BR> <BR> Print #1, "Close"
Next i
Close #1
ACADobj.Application.Visible = False
DOC.SendCommand ("filedia") & Chr(13) & ("0") & Chr(13)<BR>DOC.SendCommand ("scr") & Chr(13) & ("c:\userdata\test.scr") & Chr(13)
For i = 1 To lstBind.ListCount / 2 + 1<BR> Call Sleep(9000)<BR>Next i
<BR>DOC.SendCommand ("filedia") & Chr(13) & ("1") & Chr(13)
<BR>DOC.Close (SaveChanges)<BR>ACADobj.Application.Width = iWidth<BR>ACADobj.Application.Height = iHeight
ACADobj.Quit
If Dir("c:\userdata\test.scr") = "test.scr" Then<BR> Kill ("c:\userdata\test.scr")<BR>End If
StatusBar1.SimpleText = "Bind is successful."<BR>'MsgBox ("Bind is ok")
End Sub
Private Sub Command1_Click()
<BR> If Len(dirSource.Path) > 0 Then<BR> <BR> If Right(dirSource.Path, 1) = "\" Then<BR> txtNewPath.Text = dirSource.Path<BR> Else<BR> <BR> txtNewPath.Text = dirSource.Path + "\"<BR> End If<BR> <BR> End If
End Sub
Private Sub dirSource_Change()
<BR> fileSource.Path = dirSource.Path
<BR>End Sub
Private Sub drvSource_Change()
dirSource.Path = drvSource.Drive
End Sub
Private Sub fileSource_DblClick()<BR> <BR> Dim strfilepath As String
If fileSource.ListCount > 0 Then<BR> <BR> If Right(dirSource.Path, 1) = "\" Then<BR> strfilepath = dirSource.Path + fileSource.FileName<BR> Else<BR> strfilepath = dirSource.Path + "\" + fileSource.FileName<BR> End If<BR> <BR> If isInBindList(strfilepath) = False Then<BR> lstBind.AddItem (strfilepath)<BR> Else<BR> MsgBox ("The file " + strfilepath + " you select is already in the bind list")<BR> Exit Sub<BR> End If<BR> <BR> End If
End Sub
Private Function isInBindList(strFileItem As String) As Boolean
isInBindList = False<BR> Dim i As Integer<BR> Dim strfilepath As String<BR> <BR> For i = 0 To lstBind.ListCount - 1<BR> <BR> If lstBind.List(i) = strFileItem Then<BR> isInBindList = True<BR> End If<BR> <BR> Next i
End Function
<BR>Private Sub fileSource_KeyPress(KeyAscii As Integer)
Dim i As Integer<BR> Dim strfilepath As String<BR> <BR> If KeyAscii = 13 Then<BR> <BR> For i = 0 To fileSource.ListCount - 1<BR> <BR> If fileSource.Selected(i) = True Then<BR> If Right(dirSource.Path, 1) = "\" Then<BR> strfilepath = dirSource.Path + fileSource.List(i)<BR> Else<BR> strfilepath = dirSource.Path + "\" + fileSource.List(i)<BR> End If<BR> <BR> If isInBindList(strfilepath) = False Then<BR> lstBind.AddItem (strfilepath)<BR> Else<BR> MsgBox ("The file " + strfilepath + " you select is already in the bind list")<BR> Exit Sub<BR> End If<BR> End If<BR> <BR> Next i<BR> End If<BR>End Sub
Private Sub lstBind_DblClick()<BR> <BR> If lstBind.ListCount > 0 Then<BR> <BR> lstBind.RemoveItem (lstBind.ListIndex)<BR> <BR> End If<BR>
End Sub
我发现,当图纸比较大时,SLEEP 9 可能不够,这样CAD还在运行,同时还继续执行VB的后续命令,这样就出错了。有没有什么函数可以返回CAD执行的结果,如果测试到CAD还在运行,就不执行VB的以下的程序,直到推出CAD。 谢谢。<BR> 还好了,我的绑定会出错
页:
[1]