• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 53
    Registered: ‎07-18-2005

    Append entity.

    143 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?
    Please use plain text.
    Valued Contributor
    Posts: 53
    Registered: ‎07-18-2005

    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.
    Please use plain text.
    Valued Contributor
    Posts: 53
    Registered: ‎07-18-2005

    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
    Please use plain text.