- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
// tested on AutoCAD 2010
[CommandMethod("ResetDimValues", "rdv", CommandFlags.Modal | CommandFlags.Redraw)]
public void ResetDims()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
TypedValue[] values = new TypedValue[] { new TypedValue(0, "DIMENSION") };
SelectionFilter filter = new SelectionFilter(values);
PromptSelectionOptions opts = new PromptSelectionOptions();
opts.MessageForRemoval = "\nMust be a type of Dimension!";
opts.MessageForAdding = "\nSelect dimensions to reset : ";
opts.PrepareOptionalDetails = false;
opts.SingleOnly = false;
opts.SinglePickInSpace = false;
opts.AllowDuplicates = true;
PromptSelectionResult result = ed.GetSelection(opts, filter);
if (result.Status != PromptStatus.OK) return;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
SelectionSet sset = result.Value;
foreach (SelectedObject selobj in sset)
{
DBObject obj = tr.GetObject(selobj.ObjectId, OpenMode.ForWrite, false) as DBObject;
Dimension dim = obj as Dimension;
if (dim != null)
{
dim.DimensionText = "<>";
}
}
tr.Commit();
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\nProblem updating dimensions.\n");
ed.WriteMessage(ex.Message);
}
} |
|