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

create line from dbpoints

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


How to create line from dbpoints?

Valued Mentor
Posts: 471
Registered: ‎04-11-2010
Message 2 of 3 (161 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)
            acTrans.AddNewlyCreatedDBObject(nl, True)
        End Using
    End Sub


Gaston Nunez

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

Re: create line from dbpoints

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


Thanks a lot for the reply it worked.


Thankyou so much :smileyhappy:


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.