通过代码实现启动表格对象的breaks
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);
}
做个对论坛有益的人。
页:
[1]