|
请教各位:
创建引线标注时创建了一个AcDbMText和一个AcDbLeader ,Leader如何赋三维点的Z值?
我直接采用.NET开发手册的CODE,更改Z值如-10时,Leader的Z值仍为0,而且无法建立两者的关联性(提示运行错误!)。代码如下:
_
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 |
|