Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Namespace Test
Public Class MyCommands
<CommandMethod("Test")> _
Public Sub MyMain()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using myTrans As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = myTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = myTrans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
'' создаем Solid3d
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Wedge As Solid3d = New Solid3d()
Wedge.CreateWedge(10, 15, 20)
btr.AppendEntity(Wedge)
myTrans.AddNewlyCreatedDBObject(Wedge, True)
''вариант 1 - секущая плоскость попадает на Solid3d - работает Ok
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Plan As Plane = New Plane(Point3d.Origin, New Vector3d(1, 0, 0))
Dim SectRegion As Region = Wedge.GetSection(Plan)
SectRegion.ColorIndex = 1
btr.AppendEntity(SectRegion)
myTrans.AddNewlyCreatedDBObject(SectRegion, True)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''вариант 2 - секущая плоскость не попадает на Solid3d - происходит Fatal Error
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Plan = New Plane(New Point3d(7, 0, 0), New Vector3d(1, 0, 0))
SectRegion = Wedge.GetSection(Plan)
SectRegion.ColorIndex = 1
btr.AppendEntity(SectRegion)
myTrans.AddNewlyCreatedDBObject(SectRegion, True)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
myTrans.Commit()
End Using
End Sub
End Class
End Namespace