明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1780|回复: 0

引线标注如何赋三维点的Z值?

[复制链接]
发表于 2010-10-9 16:37:00 | 显示全部楼层 |阅读模式

请教各位:

  创建引线标注时创建了一个AcDbMText和一个AcDbLeader ,Leader如何赋三维点的Z值?

  我直接采用AutoCAD.NET开发手册的CODE,更改Z值如-10时,Leader的Z值仍为0,而且无法建立两者的关联性(提示运行错误!)。代码如下:

 

<CommandMethod("AddLeaderAnnotation")> _

    Public Sub AddLeaderAnnotation()
        '' Get the current database
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

        Dim acCurDb As Database = acDoc.Database
        '' Start a transaction
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            '' Open the Block table for read
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
                                         OpenMode.ForRead)
            '' Open the Block table record Model space for write
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                           OpenMode.ForWrite)
            '' Create the MText annotation
            Dim acMText As MText = New MText()
            acMText.SetDatabaseDefaults()
            acMText.C
            acMText.Location = New Point3d(5, 5, -10)
            acMText.Width = 2
            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acMText)
            acTrans.AddNewlyCreatedDBObject(acMText, True)
            '' Create the leader with annotation
            Dim acLdr As Leader = New Leader()
            acLdr.SetDatabaseDefaults()
            acLdr.AppendVertex(New Point3d(0, 0, -10))
            acLdr.AppendVertex(New Point3d(4, 4, -10))
            acLdr.AppendVertex(New Point3d(4, 5, -10))

            acLdr.HasArrowHead = True
            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acLdr)
            acTrans.AddNewlyCreatedDBObject(acLdr, True)

            '' Attach the annotation after the leader object is added
            acLdr.Annotation = acMText.ObjectId
            acLdr.EvaluateLeader()
            '' Commit the changes and dispose of the transaction

            acTrans.Commit()

        End Using

    End Sub

 

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 00:29 , Processed in 0.173068 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表