Message 1 of 3
Créate Cicle y Line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, how are you? The truth is that I am quite new to using VB.NET, what I want to do is:
First click on Create Circle
Second Click on the polyline is created and the first circuit is deleted and the second one is created
And all of it take it to a loop
I attach an image of what I have and what I want
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.Windows.Forms
Public Class Form1
Dim vDocument As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim vDatabasa As Database = vDocument.Database
Dim vEditor As Editor = vDocument.Editor
Dim vBlockTable As BlockTable
Dim vBlockTableRec As BlockTableRecord
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Finalize()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Hide()
Dim pPtoOpciones As PromptPointOptions = New PromptPointOptions("")
Dim pPtoResultado As PromptPointResult
pPtoOpciones.Message = vbLf & "Ingrese primer Punto: "
pPtoResultado = vEditor.GetPoint(pPtoOpciones)
Dim Pto1 As Point3d = pPtoResultado.Value
If pPtoResultado.Status = PromptStatus.Cancel Then
Me.Show()
Exit Sub
End If
pPtoOpciones.UseBasePoint = True
pPtoOpciones.BasePoint = Pto1
pPtoOpciones.Message = vbLf & "Ingrese Segundo Punto: "
pPtoResultado = vEditor.GetPoint(pPtoOpciones)
Dim Pto2 As Point3d = pPtoResultado.Value
If pPtoResultado.Status = PromptStatus.Cancel Then
Me.Show()
Exit Sub
End If
Dim x1 As Double : Dim y1 As Double : Dim z1 As Double
Dim x2 As Double : Dim y2 As Double : Dim z2 As Double
x1 = Pto1(0) : y1 = Pto1(1) : z1 = Pto1(2)
x2 = Pto2(0) : y2 = Pto2(1) : z2 = Pto2(2)
Me.Show()
Using lock As DocumentLock = vDocument.LockDocument
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
OpenMode.ForWrite)
Dim acCirc As Circle = New Circle()
acCirc.SetDatabaseDefaults()
acCirc.Center = New Point3d(Pto1(0), Pto1(1), Pto1(2))
acCirc.Radius = Val(TxtRadius.Text)
acBlkTblRec.AppendEntity(acCirc)
acTrans.AddNewlyCreatedDBObject(acCirc, True)
acTrans.Commit()
End Using
End Using
Using lock As DocumentLock = vDocument.LockDocument
Using vtransaction As Transaction = vDatabasa.TransactionManager.StartTransaction
vBlockTable = vtransaction.GetObject(vDatabasa.BlockTableId, OpenMode.ForRead)
vBlockTableRec = vtransaction.GetObject(vBlockTable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim vlinea As Line = New Line(Pto1, Pto2)
vlinea.SetDatabaseDefaults()
vlinea.ColorIndex = 1
vlinea.LineWeight = LineWeight.LineWeight013
vBlockTableRec.AppendEntity(vlinea)
vtransaction.AddNewlyCreatedDBObject(vlinea, True)
vtransaction.Commit()
MsgBox(vlinea.Length)
End Using
End Using
End Sub
End Class