.NET

Reply
Valued Contributor
sepich4567
Posts: 53
Registered: ‎07-18-2005
Message 1 of 3 (213 Views)

Append entity.

213 Views, 2 Replies
08-25-2005 08:07 AM
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?
Valued Contributor
sepich4567
Posts: 53
Registered: ‎07-18-2005
Message 2 of 3 (213 Views)

Re: Append entity.

08-25-2005 08:22 AM in reply to: sepich4567
What I am trying to do is write a program that in the simplest most understandable means possible draws a line for me.
Valued Contributor
sepich4567
Posts: 53
Registered: ‎07-18-2005
Message 3 of 3 (213 Views)

Re: Append entity.

08-25-2005 09:14 AM in reply to: sepich4567
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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.