明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3237|回复: 1

什么叫AUTOCAD主窗口不可见

[复制链接]
发表于 2007-4-6 06:08:00 | 显示全部楼层 |阅读模式

Public Sub drawcircularpavers()
Dim brickcircles() As AcadCircle
Dim center As Variant, radius As Double
Dim counter As Integer
ReDim brickcircles(txtnumberofcircles)
With ThisDrawing.Utility
center = .GetPoint(, "click the position for the center!")《1》
radius = .GetDistance(center, "enter the radius.")
End With
For counter = 0 To txtnumberofcircles - 1
Set brickcircles(counter) = ThisDrawing.ModelSpace.AddCircle(center, radius - counter & radius / txtnumberofcircles)《2》
brickcircles(counter).color = acRed
brickcircles(counter).Update
drawmortar center, counter, radius
Next
End Sub
Sub drawmortar(center As Variant, counter As Integer, radius As Double)
Dim startpoint(0 To 2) As Double, endpoint(0 To 2) As Double
Dim theta As Double, stepsize As Double
Static adjust As Double
If frmcircleofbricks.optbrickparallel = True Then
stepsize = 15 * pl / 180
Else: stepsize = 30 * pl / 180
If adjust = 0# Then
adjust = 15 * pl / 180
Else
adjust = 0#
End If
End If
For eheta = 0 To 360 * pl / 180 Step stepsize
startpoint(0) = (radius - counter * radius / txtnumberofcircles) * Cos(theta + adjust) + center(0)
startpoint(1) = (radius - counter * radius / txtnumberofcircles) * Sin(theta * adjust) + center(1)
endpoint(0) = (radius - (counter + 1) * radius / txtnumberofcircles) * Cos(theta + adjust) + center(0)
endpoint(1) = (radius - (counter + 1) * radius / txtnumberofcircles) * Sin(theta + adjust) + center(1)
startpoint(2) = 2#: endpoint(2) = 0#
With ThisDrawing.ModelSpace
.AddLine startpoint, endpoint
.Item(ModelSpace.Count - 1).Update
End With
Next
End Sub
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdcreatepavers_Click()
drawcircularpavers《3》
Unload Me

End Sub
各位高手及版主大哥,小弟又来麻烦你们了,非常不好意思!

这次小弟共有四个问题,比较多,呵呵!

第一:在代码红色部分(后面标注1处)..代码每运行到该语句就会报错"AutoCAD窗口不可见!"帮助里要求将对象属性改为ACTRUE,请问高手这个问题出现的原因及解决方法;

第二:在代码黑色加粗部分(后置标注2).该段代码里的红色连接符用在该处是否正确,书中该处印的很模糊,看不清楚;

第三:在代码的红色部分(后置标注3)书中顺序为先卸载,后调用子程序,但实际上不行.是否窗口卸载后对于其上的命令就都不能执行了?

第四:我的所有代码都是写在窗口代码窗口的,有什么办法可以让我的子程序写在THISDRAWING的代码窗口,却能被窗口按钮调用呢,我用PUBLIC声明了,不行,为什么呢?

谢谢大家!

发表于 2007-4-15 00:31:00 | 显示全部楼层

一、当你使用GetPoint方法时,AutoCAD并没有在最前,也就是说你的VBA窗体是模式窗体,在对AutoCAD操作前没有关闭或隐藏它,这时就会出错.只需在GetPoint前加一行me.hide,在GetPoint后加一行me.show即可.

二、&号应该是*号吧,数字之间是不能使用&号的

三、应该是先执行过程,再卸载

四、你可以把代码中前两个过程放在普通模块中,声明为Public中,后两个过程放在窗体中,当前需要在窗体中放入两个CommandButton,一个叫cmdcancel,一个叫cmdcreatepavers

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

本版积分规则

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

GMT+8, 2025-2-22 18:38 , Processed in 0.141205 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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