创建多引线对象(MLeader)

来源:互联网 发布:windows系统正版验证 编辑:程序博客网 时间:2024/05/18 01:25
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Imports ZwSoft.ZwCAD.Geometry


Public Class test


    <CommandMethod("AddMLeader")> _
    Public Shared Sub AddMLeader()
        Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZcDB As Database = ZcDoc.Database
        Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction
            Dim ZcBLT As BlockTable = ZcTran.GetObject(ZcDB.BlockTableId, OpenMode.ForRead)
            Dim ZcBLTR As BlockTableRecord = ZcTran.GetObject(ZcBLT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)


            Dim mleader As New MLeader()
            mleader.SetDatabaseDefaults()
            mleader.ContentType = ContentType.MTextContent


            Dim mText As New MText()
            mText.SetDatabaseDefaults()
            mText.Width = 100
            mText.TextHeight = 5
            mText.SetContentsRtf("Add a mleader")
            mText.Location = New Point3d(10, 10, 0)


            mleader.MLeaderText = mText


            Dim i As Integer = mleader.AddLeaderLine(New Point3d(10, 10, 0))
            mleader.AddFirstVertex(i, New Point3d(2, 2, 0))
            Dim j As Integer = mleader.AddLeaderLine(New Point3d(10, 10, 0))
            mleader.AddFirstVertex(j, New Point3d(20, 10, 0))


            ZcBLTR.AppendEntity(mleader)
            ZcTran.AddNewlyCreatedDBObject(mleader, True)


            ZcTran.Commit()
        End Using
    End Sub


   
End Class