.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Append entity.

2 REPLIES 2
Reply
Message 1 of 3
sepich4567
653 Views, 2 Replies

Append entity.

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?
2 REPLIES 2
Message 2 of 3
sepich4567
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.
Message 3 of 3
sepich4567
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost