你可以使用类似这样的东西:
- public void MakeMLeader(string layerName, Point3d leaderPt, Point3d labelPt, string labelText)
- {
- using (Transaction acTr = Active.TransactionManager.StartTransaction())
- {
- BlockTableRecord curSpace =
- (BlockTableRecord)acTr.GetObject(Active.Database.CurrentSpaceId, OpenMode.ForWrite);
- MLeader label = new MLeader();
- label.SetDatabaseDefaults();
- label.ContentType = ContentType.MTextContent;
- MText mText = new MText();
- mText.SetContentsRtf(labelText);
- mText.Height = 0.1;
- mText.Location = labelPt;
- label.Layer = layerName;
- label.Scale = Active.Dimscale();
- label.MText = mText;
- label.AddLeaderLine(leaderPt);
- curSpace.AppendEntity(label);
- acTr.AddNewlyCreatedDBObject(label, true);
- acTr.Commit();
- }
- }
|