如何判断布局是否已经存在
如:Layout1 public Autodesk.AutoCAD.DatabaseServices.ObjectId LayoutDictionaryId { get; }Autodesk.AutoCAD.DatabaseServices.Database 的成员
public bool Contains(string entryName)
Autodesk.AutoCAD.DatabaseServices.DBDictionary 的成员 另外有个苯办法是,遍历块表,把里面是布局的块记录取出,进而取得其布局;
public bool IsLayout { get; }
Autodesk.AutoCAD.DatabaseServices.BlockTableRecord 的成员
public Autodesk.AutoCAD.DatabaseServices.ObjectId LayoutId { set; get; }
Autodesk.AutoCAD.DatabaseServices.BlockTableRecord 的成员 sieben 发表于 2012-11-23 19:21 static/image/common/back.gif
另外有个苯办法是,遍历块表,把里面是布局的块记录取出,进而取得其布局;
public bool IsLayout { get;...
多谢多谢,用笨办法搞定!
''' <summary>
''' 判断布局是否存在
''' </summary>
''' <param name="layName">布局名字</param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function LayoutNameIndexOf(ByVal layName As String) As Boolean
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim b As Boolean = False
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim lydiid As ObjectId = db.LayoutDictionaryId
'获取数据字典
Dim lydi As DBDictionary = trans.GetObject(lydiid, OpenMode.ForRead)
'字典计数器
Dim di As DbDictionaryEnumerator = lydi.GetEnumerator()
'遍历布局
While (di.MoveNext())
Dim lyid As ObjectId = di.Value
'获取布局
Dim lyt As Layout = trans.GetObject(lyid, OpenMode.ForRead)
'因此处区分大小写,所以将名字都转化为大写后再比较
If UCase(lyt.LayoutName) = UCase(layName) Then
b = True
Exit While
End If
End While
End Using
Return b
End Function
页:
[1]