.NET

Reply
Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 1 of 3 (166 Views)
Accepted Solution

create line from dbpoints

166 Views, 2 Replies
07-04-2013 10:21 PM

Hi,

How to create line from dbpoints?

Hi, try this sub, it will create a line with default values (layer, line type, etc)

 

Private Sub AddLine(ByVal dbp1 As DBPoint, ByVal dbp2 As DBPoint)
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = HostApplicationServices.WorkingDatabase()
Using acTrans As Transaction = db.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim nl As New Line(dbp1.Position, dbp2.Position)
acBlkTblRec.AppendEntity(nl)
acTrans.AddNewlyCreatedDBObject(nl, True)
acTrans.Commit()
End Using
End Sub

 

Gaston Nunez

Valued Mentor
gasty1001
Posts: 477
Registered: ‎04-11-2010
Message 2 of 3 (162 Views)

Re: create line from dbpoints

07-04-2013 11:02 PM in reply to: gulzar25

Hi, try this sub, it will create a line with default values (layer, line type, etc)

 

Private Sub AddLine(ByVal dbp1 As DBPoint, ByVal dbp2 As DBPoint)
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = HostApplicationServices.WorkingDatabase()

        Using acTrans As Transaction = db.TransactionManager.StartTransaction()
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
            Dim nl As New Line(dbp1.Position, dbp2.Position)
            acBlkTblRec.AppendEntity(nl)
            acTrans.AddNewlyCreatedDBObject(nl, True)
            acTrans.Commit()
        End Using
    End Sub

 

Gaston Nunez

Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 3 of 3 (154 Views)

Re: create line from dbpoints

07-04-2013 11:23 PM in reply to: gasty1001

HI,

Thanks a lot for the reply it worked.

 

Thankyou so much :smileyhappy:

Gulzar

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.