Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Geometry
Public Class ZwcadApps
<CommandMethod("DetIntersect")> _
Public Shared Sub DetIntersect()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim peo As New PromptEntityOptions(vbLf & "Select first object:")
Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
If per.Status <> PromptStatus.OK Then
Return
End If
Dim EntA As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForRead)
Dim peoS As New PromptEntityOptions(vbLf & "Select second object:")
Dim perS As PromptEntityResult = ZcEd.GetEntity(peoS)
If perS.Status <> PromptStatus.OK Then
Return
End If
Dim EntB As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForRead)
Dim pts As Point3dCollection = New Point3dCollection()
EntA.IntersectWith(EntB, Intersect.OnBothOperands, pts, IntPtr.Zero, IntPtr.Zero)
If pts.Count <> 0 Then
ZcEd.WriteMessage("Selected objects have intersection point(s)!")
Else
ZcEd.WriteMessage("Selected objects have no intersection point(s)!")
End If
ZcTran.Commit()
End Using
End Sub
End Class
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Geometry
Public Class ZwcadApps
<CommandMethod("DetIntersect")> _
Public Shared Sub DetIntersect()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim peo As New PromptEntityOptions(vbLf & "Select first object:")
Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
If per.Status <> PromptStatus.OK Then
Return
End If
Dim EntA As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForRead)
Dim peoS As New PromptEntityOptions(vbLf & "Select second object:")
Dim perS As PromptEntityResult = ZcEd.GetEntity(peoS)
If perS.Status <> PromptStatus.OK Then
Return
End If
Dim EntB As Entity = ZcTran.GetObject(per.ObjectId, OpenMode.ForRead)
Dim pts As Point3dCollection = New Point3dCollection()
EntA.IntersectWith(EntB, Intersect.OnBothOperands, pts, IntPtr.Zero, IntPtr.Zero)
If pts.Count <> 0 Then
ZcEd.WriteMessage("Selected objects have intersection point(s)!")
Else
ZcEd.WriteMessage("Selected objects have no intersection point(s)!")
End If
ZcTran.Commit()
End Using
End Sub
End Class