ayrus Posted October 14, 2010 Share Posted October 14, 2010 Hi, I am wondering if it is possible to read the start and point of all the lines drawn in a autocad file using VBA or VB.Net thanks Quote Link to comment Share on other sites More sharing options...
Kerry Brown Posted October 14, 2010 Share Posted October 14, 2010 Yes, it is. Quote Link to comment Share on other sites More sharing options...
ayrus Posted October 14, 2010 Author Share Posted October 14, 2010 hi Kerry, Wondering if you have any sample code... Yes, it is. Quote Link to comment Share on other sites More sharing options...
Jeff H Posted October 14, 2010 Share Posted October 14, 2010 This will print them out to the command line This techinally does not get all lines in the drawing just the ones in model space but you could loop through the blocktable and check if IsLayout to get model and paper spaces _ Public Sub ReadAllLinesStartPoint() Dim doc As Document = DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Using tr As Transaction = db.TransactionManager.StartTransaction Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead) Dim btr As BlockTableRecord = bt(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForRead) For Each objId As ObjectId In btr Dim ent As Entity = objId.GetObject(OpenMode.ForRead) If TypeOf ent Is Line Then Dim l As Line = TryCast(ent, Line) ed.WriteMessage(vbCrLf & l.StartPoint.ToString()) End If Next tr.Commit() End Using End Sub Quote Link to comment Share on other sites More sharing options...
ayrus Posted October 18, 2010 Author Share Posted October 18, 2010 Hi jeff, Thanks you for your response. Not sure on how I could convert this to VBA in AutoCAD. Please could you help.. This will print them out to the command lineThis techinally does not get all lines in the drawing just the ones in model space but you could loop through the blocktable and check if IsLayout to get model and paper spaces _ Public Sub ReadAllLinesStartPoint() Dim doc As Document = DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Using tr As Transaction = db.TransactionManager.StartTransaction Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead) Dim btr As BlockTableRecord = bt(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForRead) For Each objId As ObjectId In btr Dim ent As Entity = objId.GetObject(OpenMode.ForRead) If TypeOf ent Is Line Then Dim l As Line = TryCast(ent, Line) ed.WriteMessage(vbCrLf & l.StartPoint.ToString()) End If Next tr.Commit() End Using End Sub Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.