.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Append entity.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
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?
Re: Append entity.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: Append entity.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.ForWrit e)
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
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.ForWrit
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
