.NET

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

create line from dbpoints

174 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

Distinguished Mentor
gasty1001
Posts: 531
Registered: ‎04-11-2010
Message 2 of 3 (170 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 (162 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.