Criação de um Retangulo/Quadrado com uma Polilyne fechada, inserido no ponto 0,0,0
Com programação VB.net a linha de código que fecha a polilinha é a seguinte:
ZWPoly.Closed = True
Dim Largura As Double = ZWEd.GetDouble(vbCr & "Qual a Largura do retangulo ?").Value
Dim Altura As Double = ZWEd.GetDouble(vbCr & "Qual a Altura do retangulo ?").Value
Public Class ZWRetanguloObject
<CommandMethod("NewRetangulo")>
Public Sub NewRetangulo()
Dim ZWDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZWEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim ZWCurDb As Database = ZWDoc.Database
Dim Largura As Double = ZWEd.GetDouble(vbCr & "Qual a Largura do retangulo ?").Value
Dim Altura As Double = ZWEd.GetDouble(vbCr & "Qual a Altura do retangulo ?").Value
Using ZWTrans As Transaction = ZWCurDb.TransactionManager.StartTransaction()
Dim ZWBlkTbl As BlockTable = ZWTrans.GetObject(ZWCurDb.BlockTableId, OpenMode.ForRead)
Dim ZWBlkTblRec As BlockTableRecord = ZWTrans.GetObject(ZWBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim ZWPoly As Polyline = New Polyline()
ZWPoly.SetDatabaseDefaults()
ZWPoly.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
ZWPoly.AddVertexAt(1, New Point2d(Largura, 0), 0, 0, 0)
ZWPoly.AddVertexAt(2, New Point2d(Largura, Altura), 0, 0, 0)
ZWPoly.AddVertexAt(3, New Point2d(0, Altura), 0, 0, 0)
ZWPoly.Closed = True
ZWBlkTblRec.AppendEntity(ZWPoly)
ZWTrans.AddNewlyCreatedDBObject(ZWPoly, True)
ZWTrans.Commit()
End Using
End Sub
End Class
Testem
Cumprimentos.
Sem comentários:
Enviar um comentário