程序中两个问题怎么解决?
一:当在CAD窗口中绘制完实体(如BOX)后,为何实体不能及时显示出来?二:程序中判定两实体是否干涉的代码如何编制?比如干涉时弹出对话框“两实体干涉”
当不干涉时弹出对话框:"两实体不干涉"
一问已解决。
二问还不会,不知怎么改?
Option Explicit
Public boxObj As Acad3DSolid<BR>Public cylinderObj As Acad3DSolid<BR>Public solidObj As Acad3DSolid
Private Sub CommandButton1_Click()<BR>Me.Hide
Dim boxLength As Double, boxWidth As Double, boxHeight As Double<BR>Dim boxCenter As Variant<BR>boxCenter = ThisDrawing.Utility.GetPoint(, "选择BOX中心:")<BR>boxLength = 250#: boxWidth = 175: boxHeight = 250#<BR> <BR>Set boxObj = ThisDrawing.ModelSpace.AddBox(boxCenter, boxLength, boxWidth, boxHeight)<BR>ThisDrawing.Regen acActiveViewport<BR>Me.Show<BR>End Sub
Private Sub CommandButton2_Click()<BR>Me.Hide
Dim cylinderCenter As Variant<BR>Dim cylinderRadius As Double<BR>Dim cylinderHeight As Double<BR>cylinderCenter = ThisDrawing.Utility.GetPoint(, "选择cylinder中心;")<BR>cylinderRadius = 125#<BR>cylinderHeight = 400#<BR> <BR>Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder(cylinderCenter, cylinderRadius, cylinderHeight)
ThisDrawing.Regen acActiveViewport<BR>Me.Show<BR>End Sub
Private Sub CommandButton3_Click()<BR>dim interference as boolean<BR>Set solidObj = boxObj.CheckInterference(cylinderObj, True)<BR>If interference= True Then<BR> <BR> MsgBox "两实体干涉"<BR> Else<BR> MsgBox "两实体不干涉"<BR>End If<BR> <BR> <BR> ThisDrawing.Regen acActiveViewport<BR> <BR>End Sub 1.在添加实体后显示对话框前加入以下代码:
Update
2.加入这样的程序:(注意把boxObj和cylinderObj两个变量的定义放到声明段中)Private Sub CommandButton3_Click()
Dim insObj As Acad3DSolid
Dim i As Long
i = ThisDrawing.ObjectIdToObject(boxObj.OwnerID).Count
Set insObj = boxObj.CheckInterference(cylinderObj, True)
If ThisDrawing.ObjectIdToObject(boxObj.OwnerID).Count > i Then
MsgBox "两对象相干涉"
insObj.Delete
Else
MsgBox "两对象不干涉"
End If
Me.Hide
End Sub 该怎么办呢难哦发表于2004-4-29 21:04:00static/image/common/back.gif一问已解决。
二问还不会,不知怎么改?
你的代码问题:<BR>CheckInterference返回的是对象,而不是布尔值。<BR><BR>
页:
[1]