- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2010-11-27 17:02:00
|
显示全部楼层
-
- public static void AddHatch(Transaction tr, BlockTableRecord btr, IEnumerable<ObjectIdCollection> idCollections, HatchPatternType patternType, string patternName, double patternAngle, double patternScale)
- {
- Hatch hatch =
- new Hatch
- {
- PatternAngle = patternAngle,
- PatternScale = patternScale,
- };
- hatch.SetDatabaseDefaults();
- hatch.SetHatchPattern(patternType, patternName);
- btr.AppendEntity(hatch);
- tr.AddNewlyCreatedDBObject(hatch, true);
- hatch.Associative = false;
- foreach (var ids in idCollections)
- {
- hatch.AppendLoop(HatchLoopTypes.External, ids);
- }
- }
- [CommandMethod("t2")]
- public static void Test2()
- {
- var db = HostApplicationServices.WorkingDatabase;
- var doc = Application.DocumentManager.GetDocument(db);
- var ed = doc.Editor;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- var btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
- Circle c = new Circle(Point3d.Origin, Vector3d.ZAxis, 8);
- btr.AppendEntity(c);
- tr.AddNewlyCreatedDBObject(c, true);
- AddHatch(tr, btr, new List<ObjectIdCollection> { new ObjectIdCollection { c.ObjectId } }, HatchPatternType.CustomDefined, "ansi31", 0, 1);
- c.Erase();
- tr.Commit();
- }
- }
|
|