我很确定你的行没有创建封闭区域,因为这是工作代码
为了确保更好地使用闭合多段线或绘制直线链测长度
取决于以前的线点,例如:
-
- ' by Tony Tanzillo
- Friend Function PolarPoint(basepoint As Point3d, angle As Double, distance As Double) As Point3d
- Return New Point3d(basepoint.X + (distance * Math.Cos(angle)), basepoint.Y + (distance * Math.Sin(angle)), basepoint.Z)
- End Function
- <CommandMethod("demoreg")> _
- Public Sub RegionDemo()
- Dim acCurDb As Database = HostApplicationServices.WorkingDatabase
- Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
- Try
- Using acTrans As Autodesk.AutoCAD.DatabaseServices.Transaction = acCurDb.TransactionManager.StartTransaction()
- Dim acBlkTbl As Autodesk.AutoCAD.DatabaseServices.BlockTable
- acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
- Dim acBlkTblRec As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord
- acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
- Dim acDBObjCol As DBObjectCollection = New DBObjectCollection()
- Dim Line1 As Line = DrawLine(New Point3d(0, 0, 0), 0.0, 100)
- Dim Line2 As Line = DrawLine(Line1.EndPoint, Math.PI / 2 - Math.PI / 6, 100)
- Dim Line3 As Line = DrawLine(Line2.EndPoint, Math.PI / 2 + Math.PI / 6, 100)
- Dim Line4 As Line = DrawLine(Line3.EndPoint, Math.PI, 100)
- Dim Line5 As Line = DrawLine(Line4.EndPoint, Math.PI * 1.5 - Math.PI / 6, 100)
- Dim Line6 As Line = DrawLine(Line5.EndPoint, Math.PI * 1.5 + Math.PI / 6, 100)
- acDBObjCol.Add(Line1)
- acDBObjCol.Add(Line2)
- acDBObjCol.Add(Line3)
- acDBObjCol.Add(Line4)
- acDBObjCol.Add(Line5)
- acDBObjCol.Add(Line6)
- ''MsgBox(Line1.EndPoint.X)
- Dim myRegionCol As DBObjectCollection = New DBObjectCollection()
- myRegionCol = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(acDBObjCol)
- Dim acRegion As Autodesk.AutoCAD.DatabaseServices.Region = DirectCast(myRegionCol(0), Autodesk.AutoCAD.DatabaseServices.Region)
- acBlkTblRec.AppendEntity(acRegion)
- acTrans.AddNewlyCreatedDBObject(acRegion, True)
- ' ---> here you might be want to erase and dispose lines after
- acTrans.Commit()
- End Using
- Catch ex As System.Exception
- MsgBox("Error" + vbLf + ex.ToString)
- End Try
- End Sub
~'J'~ |