Append entity.

Append entity.

Anonymous
Not applicable
779 Views
2 Replies
Message 1 of 3

Append entity.

Anonymous
Not applicable
The following code will not compile due to errors:

Dim corner1 As New Point2d(0, 0)
Dim corner2 As New Point2d(10, 0)
Dim ln As New Line2d(corner1, corner2)
btr.AppendEntity(ln) 'Add the reference to ModelSpace
trans.AddNewlyCreatedDBObject(ln, True) 'Let the transaction know about it
trans.Commit()

What is it that I am doing wrong?
0 Likes
780 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
What I am trying to do is write a program that in the simplest most understandable means possible draws a line for me.
0 Likes
Message 3 of 3

Anonymous
Not applicable
This is what I was after:

Imports System
Imports System.Type
Imports System.CLSCompliantAttribute
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput'
Imports Autodesk.AutoCAD.Geometry

Public Class Class1
_
Public Sub Draw()
Dim coord1 As New Point3d(0,0,0)
Dim coord2 As New Point3d(0,10,0)
Dim acadLine As Line
Dim acadBT As BlockTable
Dim acadBTR As BlockTableRecord
Dim acadDB As Database = HostApplicationServices.WorkingDatabase
Dim acadTrans As Transaction
acadTrans = acadDB.TransactionManager.StartTransaction()

Try
acadBT = acadTrans.GetObject(acadDB.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
acadBTR = acadTrans.GetObject(acadBT(acadBTR.ModelSpace), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
acadLine = New Line(coord1, coord2)
acadBTR.AppendEntity(acadLine)
acadTrans.AddNewlyCreatedDBObject(acadLine, True)
acadTrans.Commit()
Catch
acadTrans.Abort()
Finally
If Not isnothing(acadTrans) Then acadTrans.Dispose()
If Not isnothing(acadLine) Then acadLine.dispose()
If Not isnothing(acadBT) Then acadBT.dispose()
If Not isnothing(acadDB) Then acadDB.dispose()
End Try
End Sub
End Class
0 Likes