明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1092|回复: 0

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

[复制链接]
发表于 2008-4-3 10:56:00 | 显示全部楼层 |阅读模式

[求助]在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

红色语句运行时有误,应如何改?请高人指教!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 11:55 , Processed in 0.154551 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表