Тема: Создание штриховки

Добрый день!
Подскажите почему не получается заштриховать внутреннюю часть пересекаемых объектов?

[CommandMethod("testHatch", CommandFlags.UsePickSet)]
        static public void testHatch()
        {
            Document aDoc = AcAp.Application.DocumentManager.MdiActiveDocument;
            Database db = aDoc.Database;
            Editor ed = aDoc.Editor;

            using (DocumentLock acLckDoc = aDoc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                    ObjectIdCollection lnIds = new ObjectIdCollection();

                    Circle crc = new Circle();
                    crc.Center = new Point3d(0, 0, 0);
                    crc.Radius = 10;
                    lnIds.Add(btr.AppendEntity(crc));
                    tr.AddNewlyCreatedDBObject(crc, true);
                    {
                        Line ln = new Line();
                        ln.StartPoint = new Point3d(0, 0, 0);
                        ln.EndPoint = new Point3d(15, 0, 0);
                        ln.TransformBy(Matrix3d.Rotation(Math.PI / 2, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        lnIds.Add(btr.AppendEntity(ln));
                        tr.AddNewlyCreatedDBObject(ln, true);
                    }
                    {
                        Line ln = new Line();
                        ln.StartPoint = new Point3d(0, 0, 0);
                        ln.EndPoint = new Point3d(15, 0, 0);
                        ln.TransformBy(Matrix3d.Rotation(Math.PI, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        lnIds.Add(btr.AppendEntity(ln));
                        tr.AddNewlyCreatedDBObject(ln, true);
                    }

                    Hatch oHatch = new Hatch();
                    btr.AppendEntity(oHatch);
                    tr.AddNewlyCreatedDBObject(oHatch, true);
                    oHatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
                    oHatch.Associative = true;
                    oHatch.AppendLoop(HatchLoopTypes.Default, lnIds);
                    oHatch.EvaluateHatch(true);

                    lnIds.Clear();
                    tr.Commit();
                }

            }

        }

Выдает ошибку eInvalidInput
Спасибо

Re: Создание штриховки

Попробуй по-другому

        [CommandMethod("tho", CommandFlags.UsePickSet)]
        static public void makeHatch()
        {
            Document aDoc = AcAp.Application.DocumentManager.MdiActiveDocument;
            Database db = aDoc.Database;
            Editor ed = aDoc.Editor;

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                    ObjectIdCollection lnIds = new ObjectIdCollection();
                    DBObjectCollection objs = new DBObjectCollection();
                    Circle crc = new Circle();
                    crc.Center = new Point3d(0, 0, 0);
                    crc.Radius = 10;
                    btr.AppendEntity(crc);
                    tr.AddNewlyCreatedDBObject(crc, true);
               
                        Line ln1 = new Line();
                        ln1.StartPoint = new Point3d(0, 0, 0);
                        ln1.EndPoint = new Point3d(-crc.Radius, 0, 0);
                      //  ln1.TransformBy(Matrix3d.Rotation(Math.PI / 2, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        btr.AppendEntity(ln1);
                        tr.AddNewlyCreatedDBObject(ln1, true);
                        objs.Add(ln1);
               
            
                        Line ln2 = new Line();
                        ln2.StartPoint = new Point3d(0, 0, 0);
                        ln2.EndPoint = new Point3d(0, crc.Radius, 0);
                      //  ln2.TransformBy(Matrix3d.Rotation(Math.PI, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, new Point3d(0, 0, 0)));
                        btr.AppendEntity(ln2);
                        tr.AddNewlyCreatedDBObject(ln2, true);
                        objs.Add(ln2);
         
                    {

                        Arc arc = new Arc(new Point3d(0, 0, 0), Vector3d.ZAxis, crc.Radius, Math.PI, Math.PI/2);
                       //       OR:     //
                       // Arc arc = new Arc(new Point3d(0, 0, 0), crc.Radius, Math.PI / 2, Math.PI);
                        arc.Normal = ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis;
                        btr.AppendEntity(arc);
                        tr.AddNewlyCreatedDBObject(arc, true);
                        objs.Add(arc);
                    }
                    Region reg = new Region();
                    DBObjectCollection regs = Region.CreateFromCurves(objs);
                    reg = (Region)regs[0];
                    lnIds.Add(btr.AppendEntity(reg));
                    tr.AddNewlyCreatedDBObject(reg, true);
                    Hatch oHatch = new Hatch();
                    btr.AppendEntity(oHatch);
                    tr.AddNewlyCreatedDBObject(oHatch, true);
                    oHatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
                    oHatch.Associative = true;
                    oHatch.AppendLoop(HatchLoopTypes.Default, lnIds);
                    oHatch.EvaluateHatch(true);
                    ln1.EndPoint = new Point3d(-15, 0, 0);
                    ln2.EndPoint = new Point3d(0, 15, 0);
                    tr.Commit();
                }

        } 

Re: Создание штриховки

Спсибо за помощь, идея ясна!

(изменено: Sergey Shevtsov, 10 февраля 2014г. 13:47:01)

Re: Создание штриховки

Уважаемы fixo, еще раз спасибо, с пересекаемыми объектами понял что нужно некий контур создать для штриховки, а для замкнутого блока фигуристой формы можно будет без контура обойтись? Например если штриховке просто ObjectId блока подсунуть?