zfj8565 发表于 2008-4-3 10:56:00

[求助]在CAD的vba编程中,如何让vba运行窗口隐藏,显示cad图形并选点?

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