ZWCad+
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.Geometry
Public Class Class1
<CommandMethod("Poly")> _
Public Sub proj1()
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim Db As Database = Doc.Database
Using Trans As Transaction = Db.TransactionManager.StartTransaction()
Dim BlkTbl As BlockTable = Trans.GetObject(Db.BlockTableId, OpenMode.ForRead)
Dim BlkTblRec As BlockTableRecord = Trans.GetObject(BlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim Poly As Polyline = New Polyline()
Poly.SetDatabaseDefaults()
Poly.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
Poly.AddVertexAt(1, New Point2d(5, 5), 0, 0, 0)
Poly.AddVertexAt(2, New Point2d(10, 0), 0, 0, 0)
BlkTblRec.AppendEntity(Poly)
Trans.AddNewlyCreatedDBObject(Poly, True)
Trans.Commit()
End Using
End Sub
End Class
Autocad
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Public Class Class1
<CommandMethod("Poly")> _
Public Sub proj1()
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim Db As Database = Doc.Database
Using Trans As Transaction = Db.TransactionManager.StartTransaction()
Dim BlkTbl As BlockTable = Trans.GetObject(Db.BlockTableId, OpenMode.ForRead)
Dim BlkTblRec As BlockTableRecord = Trans.GetObject(BlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim Poly As Polyline = New Polyline()
Poly.SetDatabaseDefaults()
Poly.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
Poly.AddVertexAt(1, New Point2d(5, 5), 0, 0, 0)
Poly.AddVertexAt(2, New Point2d(10, 0), 0, 0, 0)
BlkTblRec.AppendEntity(Poly)
Trans.AddNewlyCreatedDBObject(Poly, True)
Trans.Commit()
End Using
End Sub
End Class
Sem comentários:
Enviar um comentário