AutoCAD2016 LayoutManager.Current.GetLayoutId(layoutName) 结果为空
https://blog.csdn.net/qqider/article/details/71124601
Public Shared Function GetLayoutId(db As Database, name As String) As ObjectId
Dim layoutId As New ObjectId()
Dim bt As BlockTable = TryCast(db.BlockTableId.GetObject(OpenMode.ForRead), BlockTable)
For Each btrId As ObjectId In bt
Dim btr As BlockTableRecord = CType(btrId.GetObject(OpenMode.ForRead), BlockTableRecord)
If btr.IsLayout Then
Dim layout As Layout = CType(btr.LayoutId.GetObject(OpenMode.ForRead), Layout)
If layout.LayoutName.CompareTo(name) = 0 Then
layoutId = btr.LayoutId
Exit For
End If
End If
Next
Return layoutId
End Function
Public Shared Function GetLayoutId(Name As String) As ObjectId
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim lays As DBDictionary = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead)
For Each item As DBDictionaryEntry In lays
If item.Key = Name Then
Return item.Value
End If
Next
acTrans.Abort()
End Using
End Function
[本日志由 tiancao1001 于 2019-04-19 01:23 PM 编辑]
暂时没有评论