- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
//Create region from connected arcs and lines
[CommandMethod("craw")]
public static void CreateRegionFromConnected()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
DBObjectCollection objs = new DBObjectCollection();
DBObjectCollection regcoll = new DBObjectCollection();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
TypedValue[] tvs = new TypedValue[] { new TypedValue(0, "line,arc") };
Point3dCollection points = new Point3dCollection();
SelectionFilter sf = new SelectionFilter(tvs);
PromptSelectionResult sres = ed.GetSelection(sf);
if (sres.Status != PromptStatus.OK)
{
ed.WriteMessage("\nInvalid selection!");
return;
}
foreach (SelectedObject selobj in sres.Value)
{
DBObject obj = tr.GetObject(selobj.ObjectId, OpenMode.ForWrite, false) as DBObject;
objs.Add(obj);
}
regcoll = Region.CreateFromCurves(objs);
Region reg = regcoll[0] as Region;
btr.AppendEntity(reg);
tr.AddNewlyCreatedDBObject(reg, true);
// you might be want to remove the parent objects here,
// because of DELOBJ variable did not effect :
//foreach (DBObject obj in objs)
// obj.Erase(); // uncomment this code block if needs
tr.Commit();
}
} |
|