Translate

segunda-feira, 16 de maio de 2011

VB.net - criar um quadrado com os cantos arredondados

 Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry

Public Class Class1

    <CommandMethod("retanguloarco")> _
    Public Sub Proj1()

        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database

        ' Iniciar transação
        Using trans As Transaction = db.TransactionManager.StartTransaction

            Dim ms As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

            ''Criação do Estribo com linhas e arcos

            Dim novalinha As New Line(New Point3d(0, 0.03, 0), New Point3d(0, 0.97, 0))
            ms.AppendEntity(novalinha) ' adicionar ao model space
            trans.AddNewlyCreatedDBObject(novalinha, True) ' informar a transação

            Dim novoarco As New Arc(New Point3d(0.03, 0.03, 0), 0.03, (180 * Math.PI / 180), (270 * Math.PI / 180))
            ms.AppendEntity(novoarco)
            trans.AddNewlyCreatedDBObject(novoarco, True)

            Dim novalinha1 As New Line(New Point3d(0.03, 1, 0), New Point3d(0.97, 1.0, 0))
            ms.AppendEntity(novalinha1) ' adicionar ao model space
            trans.AddNewlyCreatedDBObject(novalinha1, True) ' informar a transação

            Dim novoarco1 As New Arc(New Point3d(0.03, 0.97, 0), 0.03, (90 * Math.PI / 180), (180 * Math.PI / 180))
            ms.AppendEntity(novoarco1)
            trans.AddNewlyCreatedDBObject(novoarco1, True)

            Dim novalinha2 As New Line(New Point3d(1, 0.97, 0), New Point3d(1, 0.03, 0))
            ms.AppendEntity(novalinha2) ' adicionar ao model space
            trans.AddNewlyCreatedDBObject(novalinha2, True) ' informar a transação

            Dim novoarco2 As New Arc(New Point3d(0.97, 0.97, 0), 0.03, (0 * Math.PI / 180), (90 * Math.PI / 180))
            ms.AppendEntity(novoarco2)
            trans.AddNewlyCreatedDBObject(novoarco2, True)

            Dim novalinha3 As New Line(New Point3d(0.97, 0, 0), New Point3d(0.03, 0, 0))
            ms.AppendEntity(novalinha3) ' adicionar ao model space
            trans.AddNewlyCreatedDBObject(novalinha3, True) ' informar a transação

            Dim novoarco3 As New Arc(New Point3d(0.97, 0.03, 0), 0.03, (270 * Math.PI / 180), 0)
            ms.AppendEntity(novoarco3)
            trans.AddNewlyCreatedDBObject(novoarco3, True)

            trans.Commit() ' confirmar a transação sempre no fim da transacção

            Application.AcadApplication.zoomextents() 'zoom extents
        End Using ' Fechar transação
    End Sub
End Class

Sem comentários:

Enviar um comentário