马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Enabling Table breaks through code
问题:
I would like to enable table breaks just the way AutoCAD does when clicking on the small triangular grip. Can you provide a sample code for this ?
解答:
There are properties and methods that help in configuring the table breaks. The sample code provided here may require changes to suit your needs. Here is a sample code :
- Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database db = activeDoc.Database;
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- PromptEntityOptions peo = new PromptEntityOptions("Select a table : ");
- peo.SetRejectMessage("Please select the table to modify");
- peo.AddAllowedClass(typeof(Table), true);
- PromptEntityResult per = ed.GetEntity(peo);
- if (per.Status != PromptStatus.OK)
- return;
- ObjectId oid = per.ObjectId;
- try
- {
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Table table = tr.GetObject(oid, OpenMode.ForWrite) as Table;
- table.BreakOptions = TableBreakOptions.EnableBreaking & TableBreakOptions.RepeatTopLabels;
- table.BreakFlowDirection = TableBreakFlowDirection.Right;
- table.BreakEnabled = true;
- table.FlowDirection = FlowDirection.LeftToRight;
- table.SetBreakHeight(0, table.Height / 3.0);
- table.SetBreakOffset(0, Vector3d.XAxis * 2.0);
- table.SetBreakSpacing(25);
- table.RecomputeTableBlock(true);
- tr.Commit();
- }
- }
- catch (System.Exception ex)
- {
- ed.WriteMessage(ex.Message);
- }
|