[求助]在CAD的vba编程中,如何让vba运行窗口隐藏,显示cad图形并选点? 附我的vba代码(有模块1和过程zfj),为啥运行会是僵死状态? Public Sub zfj() Dim AcadApp As AutoCAD.AcadApplication Set AcadApp = GetObject(, "AutoCAD.Application") Dim Mydocument As AcadDocument Set Mydocument = AcadApp.ActiveDocument Dim Myentity As AcadPolygonMesh Dim Mysel As AcadSelectionSet Dim fil_type(0) As Integer Dim fil_data(0) As Variant Dim Mycoordinates As Variant fil_type(0) = 0 fil_data(0) = "PolygonMesh" On Error Resume Next If Not IsNull(Mydocument.SelectionSets.Item("Mysel")) Then Set Mysel = Mydocument.SelectionSets.Item("Mysel") Mysel.Delete End If Set Mysel = Mydocument.SelectionSets.Add("Mysel") Dim i, j, k As Integer Me.hide Mysel.SelectOnScreen Me.show For Each Myentity In Mysel Mycoordinates = Myentity.Coordinates Next Open "D:\zfj\ory.dat" For Append As #1 For i = 0 To (j * 6 - 1) Step 6 Print #1, "gen zone brick size 1,1,1" & " &" Print #1, "p0" & "(" & Round(Mycoordinates(i), 4) & "," & Round(Mycoordinates(i + 1), 4) & "," & Round(Mycoordinates(i + 2), 4) & ")&" Print #1, "p1" & "(" & Round(Mycoordinates(i + 3), 4) & "," & Round(Mycoordinates(i + 4), 4) & "," & Round(Mycoordinates(i + 5), 4) & ")&" Print #1, "p2" & "(" & Round(Mycoordinates(i), 4) & "," & Round(Mycoordinates(i + 1), 4) & "," & Round((Mycoordinates(i + 2) - 1), 4) & ")&" Print #1, "p3" & "(" & Round(Mycoordinates(i + 6), 4) & "," & Round(Mycoordinates(i + 7), 4) & "," & Round(Mycoordinates(i + 8), 4) & ")&" Print #1, "p4" & "(" & Round(Mycoordinates(i + 3), 4) & "," & Round(Mycoordinates(i + 4), 4) & "," & Round(Mycoordinates(i + 5) - 1, 4) & ")&" Print #1, "p5" & "(" & Round(Mycoordinates(i + 6), 4) & "," & Round(Mycoordinates(i + 7), 4) & "," & Round(Mycoordinates(i + 8) - 1, 4) & ")&" Print #1, "p6" & "(" & Round(Mycoordinates(i + 9), 4) & "," & Round(Mycoordinates(i + 10), 4) & "," & Round(Mycoordinates(i + 11), 4) & ")&" Print #1, "p7" & "(" & Round(Mycoordinates(i + 9), 4) & "," & Round(Mycoordinates(i + 10), 4) & "," & Round(Mycoordinates(i + 11) - 1, 4) & ")" Next Print #1, ";*****************************" Close #1 Mysel.Delete end End Sub
红色语句运行时有误,应如何改?请高人指教! |